mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 10:46:00 +08:00
Merge branch 'master' into careminster-presence-refactor
This commit is contained in:
@@ -169,7 +169,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||
// sanity check:
|
||||
if (c.Sender == null)
|
||||
{
|
||||
m_log.ErrorFormat("[CHAT] OnChatFromClient from {0} has empty Sender field!", sender);
|
||||
m_log.ErrorFormat("[CHAT]: OnChatFromClient from {0} has empty Sender field!", sender);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -234,8 +234,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||
if (message.Length >= 1000) // libomv limit
|
||||
message = message.Substring(0, 1000);
|
||||
|
||||
// m_log.DebugFormat("[CHAT]: DCTA: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, c.Type, sourceType);
|
||||
// m_log.DebugFormat(
|
||||
// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}",
|
||||
// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType);
|
||||
|
||||
HashSet<UUID> receiverIDs = new HashSet<UUID>();
|
||||
|
||||
foreach (Scene s in m_scenes)
|
||||
{
|
||||
s.ForEachScenePresence(
|
||||
@@ -250,13 +254,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||
// objects on a parcel with access restrictions
|
||||
if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
|
||||
{
|
||||
TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix+fromName, c.Type, message, sourceType);
|
||||
if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType))
|
||||
receiverIDs.Add(presence.UUID);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
(scene as Scene).EventManager.TriggerOnChatToClients(
|
||||
fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
|
||||
}
|
||||
|
||||
static private Vector3 CenterOfRegion = new Vector3(128, 128, 30);
|
||||
@@ -294,6 +302,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||
}
|
||||
|
||||
// m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
|
||||
HashSet<UUID> receiverIDs = new HashSet<UUID>();
|
||||
|
||||
if (c.Scene != null)
|
||||
{
|
||||
((Scene)c.Scene).ForEachScenePresence
|
||||
@@ -314,18 +324,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||
|
||||
client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID,
|
||||
(byte)sourceType, (byte)ChatAudibleLevel.Fully);
|
||||
receiverIDs.Add(presence.UUID);
|
||||
}
|
||||
);
|
||||
(c.Scene as Scene).EventManager.TriggerOnChatToClients(
|
||||
fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected virtual void TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
|
||||
/// <summary>
|
||||
/// Try to send a message to the given presence
|
||||
/// </summary>
|
||||
/// <param name="presence">The receiver</param>
|
||||
/// <param name="fromPos"></param>
|
||||
/// <param name="regionPos">/param>
|
||||
/// <param name="fromAgentID"></param>
|
||||
/// <param name="fromName"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="src"></param>
|
||||
/// <returns>true if the message was sent to the receiver, false if it was not sent due to failing a
|
||||
/// precondition</returns>
|
||||
protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
|
||||
UUID fromAgentID, string fromName, ChatTypeEnum type,
|
||||
string message, ChatSourceType src)
|
||||
{
|
||||
// don't send stuff to child agents
|
||||
if (presence.IsChildAgent) return;
|
||||
if (presence.IsChildAgent) return false;
|
||||
|
||||
Vector3 fromRegionPos = fromPos + regionPos;
|
||||
Vector3 toRegionPos = presence.AbsolutePosition +
|
||||
@@ -338,12 +363,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||
type == ChatTypeEnum.Say && dis > m_saydistance ||
|
||||
type == ChatTypeEnum.Shout && dis > m_shoutdistance)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: should change so the message is sent through the avatar rather than direct to the ClientView
|
||||
presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName,
|
||||
fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully);
|
||||
fromAgentID, (byte)src, (byte)ChatAudibleLevel.Fully);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
|
||||
|
||||
@@ -598,7 +598,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
try
|
||||
{
|
||||
|
||||
XmlRpcResponse GridResp = GridReq.Send(reginfo.ServerURI, 3000);
|
||||
XmlRpcResponse GridResp = GridReq.Send("http://" + reginfo.ExternalHostName + ":" + reginfo.HttpPort, 3000);
|
||||
|
||||
Hashtable responseData = (Hashtable)GridResp.Value;
|
||||
|
||||
@@ -620,8 +620,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||
}
|
||||
catch (WebException e)
|
||||
{
|
||||
m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0}} the host didn't respond ({2})",
|
||||
reginfo.ServerURI, e.Message);
|
||||
m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to http://{0}:{1} the host didn't respond ({2})",
|
||||
reginfo.ExternalHostName, reginfo.HttpPort, e.Message);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -33,6 +33,7 @@ using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
@@ -50,6 +51,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// The maximum major version of archive that we can read. Minor versions shouldn't need a max number since version
|
||||
/// bumps here should be compatible.
|
||||
/// </summary>
|
||||
public static int MAX_MAJOR_VERSION = 0;
|
||||
|
||||
protected TarArchiveReader archive;
|
||||
|
||||
private UserAccount m_userInfo;
|
||||
@@ -133,7 +140,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
|
||||
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
|
||||
{
|
||||
if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
|
||||
if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
|
||||
{
|
||||
LoadControlFile(filePath, data);
|
||||
}
|
||||
else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
|
||||
{
|
||||
if (LoadAsset(filePath, data))
|
||||
successfulAssetRestores++;
|
||||
@@ -461,5 +472,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load control file
|
||||
/// </summary>
|
||||
/// <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);
|
||||
string version = string.Format("{0}.{1}", majorVersion, minorVersion);
|
||||
|
||||
if (majorVersion > MAX_MAJOR_VERSION)
|
||||
{
|
||||
throw new Exception(
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,9 +123,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
|
||||
try
|
||||
{
|
||||
// We're almost done. Just need to write out the control file now
|
||||
m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile());
|
||||
m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
|
||||
m_archiveWriter.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -216,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,6 +274,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
|
||||
m_archiveWriter = new TarArchiveWriter(m_saveStream);
|
||||
|
||||
// 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.");
|
||||
|
||||
if (inventoryFolder != null)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
@@ -399,13 +401,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
/// <returns></returns>
|
||||
public static string Create0p1ControlFile()
|
||||
{
|
||||
int majorVersion = 0, minorVersion = 1;
|
||||
|
||||
m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion);
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
XmlTextWriter xtw = new XmlTextWriter(sw);
|
||||
xtw.Formatting = Formatting.Indented;
|
||||
xtw.WriteStartDocument();
|
||||
xtw.WriteStartElement("archive");
|
||||
xtw.WriteAttributeString("major_version", "0");
|
||||
xtw.WriteAttributeString("minor_version", "1");
|
||||
xtw.WriteAttributeString("major_version", majorVersion.ToString());
|
||||
xtw.WriteAttributeString("minor_version", minorVersion.ToString());
|
||||
xtw.WriteEndElement();
|
||||
|
||||
xtw.Flush();
|
||||
|
||||
Reference in New Issue
Block a user