mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
Formatting cleanup.
This commit is contained in:
@@ -122,24 +122,24 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||
|
||||
IClientAPI client = presence.ControllingClient;
|
||||
|
||||
if ((c.Type == ChatTypeEnum.Owner) &&
|
||||
(null != c.SenderObject) &&
|
||||
if ((c.Type == ChatTypeEnum.Owner) &&
|
||||
(null != c.SenderObject) &&
|
||||
(((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
|
||||
return;
|
||||
|
||||
|
||||
if (null == c.SenderObject)
|
||||
client.SendChatMessage(c.Message, (byte)c.Type,
|
||||
pos, c.From, LLUUID.Zero,
|
||||
client.SendChatMessage(c.Message, (byte)c.Type,
|
||||
pos, c.From, LLUUID.Zero,
|
||||
(byte)ChatSourceType.Agent,
|
||||
(byte)ChatAudibleLevel.Fully);
|
||||
else
|
||||
client.SendChatMessage(c.Message, (byte)c.Type,
|
||||
pos, c.From, LLUUID.Zero,
|
||||
client.SendChatMessage(c.Message, (byte)c.Type,
|
||||
pos, c.From, LLUUID.Zero,
|
||||
(byte)ChatSourceType.Object,
|
||||
(byte)ChatAudibleLevel.Fully);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void SimChat(Object sender, ChatFromViewerArgs e)
|
||||
{
|
||||
// early return if not on public or debug channel
|
||||
@@ -187,13 +187,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||
if (e.Channel == DEBUG_CHANNEL)
|
||||
{
|
||||
TrySendChatMessage(presence, fromPos, regionPos,
|
||||
fromID, fromName, e.Type,
|
||||
fromID, fromName, e.Type,
|
||||
message, ChatSourceType.Object);
|
||||
}
|
||||
else
|
||||
{
|
||||
TrySendChatMessage(presence, fromPos, regionPos,
|
||||
fromID, fromName, e.Type,
|
||||
fromID, fromName, e.Type,
|
||||
message, ChatSourceType.Agent);
|
||||
}
|
||||
});
|
||||
@@ -224,16 +224,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||
LLVector3 fromRegionPos = fromPos + regionPos;
|
||||
LLVector3 toRegionPos = presence.AbsolutePosition + regionPos;
|
||||
int dis = Math.Abs((int) Util.GetDistanceTo(toRegionPos, fromRegionPos));
|
||||
|
||||
|
||||
if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
|
||||
type == ChatTypeEnum.Say && dis > m_saydistance ||
|
||||
type == ChatTypeEnum.Shout && dis > m_shoutdistance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 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,
|
||||
presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName,
|
||||
fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||
{
|
||||
public class IRCBridgeModule : IRegionModule
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private const int DEBUG_CHANNEL = 2147483647;
|
||||
@@ -68,7 +68,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((m_config = config.Configs["IRC"]) == null)
|
||||
if ((m_config = config.Configs["IRC"]) == null)
|
||||
{
|
||||
m_log.InfoFormat("[IRC] module not configured");
|
||||
return;
|
||||
@@ -85,7 +85,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||
m_log.Info("[IRC] module not configured");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
lock (m_syncInit)
|
||||
{
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||
m_irc_connector.Name = "IRCConnectorThread";
|
||||
m_irc_connector.IsBackground = true;
|
||||
}
|
||||
m_log.InfoFormat("[IRC] initialized for {0}, nick: {1} ", scene.RegionInfo.RegionName,
|
||||
m_log.InfoFormat("[IRC] initialized for {0}, nick: {1} ", scene.RegionInfo.RegionName,
|
||||
m_defaultzone);
|
||||
}
|
||||
}
|
||||
@@ -221,9 +221,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||
|
||||
if (e.Message.StartsWith("/me ") && (null != avatar))
|
||||
e.Message = String.Format("{0} {1}", fromName, e.Message.Substring(4));
|
||||
|
||||
|
||||
// this is to keep objects from talking to IRC
|
||||
if (m_irc.Connected && (avatar != null))
|
||||
if (m_irc.Connected && (avatar != null))
|
||||
m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, e.Message);
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||
if ((m_irc.Enabled) && (m_irc.Connected))
|
||||
{
|
||||
m_log.DebugFormat("[IRC] {0} logging on", clientName);
|
||||
m_irc.PrivMsg(m_irc.Nick, "Sim",
|
||||
m_irc.PrivMsg(m_irc.Nick, "Sim",
|
||||
String.Format("notices {0} logging on", clientName));
|
||||
}
|
||||
m_last_new_user = clientName;
|
||||
@@ -310,7 +310,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||
m_log.InfoFormat("[IRC]: {0} logging out", clientName);
|
||||
}
|
||||
|
||||
if (m_last_new_user == clientName)
|
||||
if (m_last_new_user == clientName)
|
||||
m_last_new_user = null;
|
||||
}
|
||||
}
|
||||
@@ -489,7 +489,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[IRC] cannot connect to {0}:{1}: {2}",
|
||||
m_log.ErrorFormat("[IRC] cannot connect to {0}:{1}: {2}",
|
||||
m_server, m_port, e.Message);
|
||||
}
|
||||
return m_connected;
|
||||
@@ -617,16 +617,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||
|
||||
// is message "\001ACTION foo
|
||||
// bar\001"? -> "/me foo bar"
|
||||
if ((1 == c.Message[0]) && c.Message.Substring(1).StartsWith("ACTION"))
|
||||
if ((1 == c.Message[0]) && c.Message.Substring(1).StartsWith("ACTION"))
|
||||
c.Message = String.Format("/me {0}", c.Message.Substring(8, c.Message.Length - 9));
|
||||
|
||||
|
||||
foreach (Scene scene in m_scenes)
|
||||
{
|
||||
c.Scene = scene;
|
||||
scene.EventManager.TriggerOnChatBroadcast(this, c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Thread.Sleep(150);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -569,7 +569,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
|
||||
{
|
||||
foreach (ListenerInfo l in list)
|
||||
{
|
||||
if(l.GetItemID() == itemID)
|
||||
if (l.GetItemID() == itemID)
|
||||
data.AddRange(l.GetSerializationData());
|
||||
}
|
||||
}
|
||||
@@ -582,14 +582,14 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
|
||||
int idx = 0;
|
||||
Object[] item = new Object[6];
|
||||
|
||||
while(idx < data.Length)
|
||||
while (idx < data.Length)
|
||||
{
|
||||
Array.Copy(data, idx, item, 0, 6);
|
||||
|
||||
ListenerInfo info =
|
||||
ListenerInfo.FromData(localID, itemID, hostID, item);
|
||||
|
||||
if(!m_listeners.ContainsKey((int)item[2]))
|
||||
if (!m_listeners.ContainsKey((int)item[2]))
|
||||
m_listeners.Add((int)item[2], new List<ListenerInfo>());
|
||||
m_listeners[(int)item[2]].Add(info);
|
||||
|
||||
|
||||
@@ -160,9 +160,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
|
||||
*
|
||||
* Generate a LLUUID channel key and add it and
|
||||
* the prim id to dictionary <channelUUID, primUUID>
|
||||
*
|
||||
*
|
||||
* A custom channel key can be proposed.
|
||||
* Otherwise, passing LLUUID.Zero will generate
|
||||
* Otherwise, passing LLUUID.Zero will generate
|
||||
* and return a random channel
|
||||
*
|
||||
* First check if there is a channel assigned for
|
||||
|
||||
@@ -37,37 +37,37 @@ using log4net;
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Region.Environment
|
||||
{
|
||||
{
|
||||
/// <summary>
|
||||
/// Method called when all the necessary assets for an archive request have been received.
|
||||
/// </summary>
|
||||
public delegate void AssetsRequestCallback(IDictionary<LLUUID, AssetBase> assets);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles an individual archive request
|
||||
/// </summary>
|
||||
public class ArchiveRequest
|
||||
{
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
||||
private Scene m_scene;
|
||||
private string m_savePath;
|
||||
|
||||
|
||||
private string m_serializedEntities;
|
||||
|
||||
|
||||
public ArchiveRequest(Scene scene, string savePath)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_savePath = savePath;
|
||||
|
||||
|
||||
ArchiveRegion();
|
||||
}
|
||||
|
||||
|
||||
protected void ArchiveRegion()
|
||||
{
|
||||
m_log.Warn("[ARCHIVER]: Archive region not yet implemented");
|
||||
|
||||
Dictionary<LLUUID, int> textureUuids = new Dictionary<LLUUID, int>();
|
||||
Dictionary<LLUUID, int> textureUuids = new Dictionary<LLUUID, int>();
|
||||
|
||||
List<EntityBase> entities = m_scene.GetEntities();
|
||||
|
||||
@@ -76,14 +76,14 @@ namespace OpenSim.Region.Environment
|
||||
if (entity is SceneObjectGroup)
|
||||
{
|
||||
SceneObjectGroup sceneObject = (SceneObjectGroup)entity;
|
||||
|
||||
|
||||
foreach (SceneObjectPart part in sceneObject.GetParts())
|
||||
{
|
||||
LLUUID texture = new LLUUID(part.Shape.TextureEntry, 0);
|
||||
textureUuids[texture] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_serializedEntities = SerializeObjects(entities);
|
||||
|
||||
@@ -91,30 +91,30 @@ namespace OpenSim.Region.Environment
|
||||
{
|
||||
m_log.DebugFormat("[ARCHIVER]: Successfully got serialization for {0} entities", entities.Count);
|
||||
m_log.DebugFormat("[ARCHIVER]: Requiring save of {0} textures", textureUuids.Count);
|
||||
|
||||
|
||||
// Asynchronously request all the assets required to perform this archive operation
|
||||
new AssetsRequest(ReceivedAllAssets, m_scene.AssetCache, textureUuids.Keys);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected internal void ReceivedAllAssets(IDictionary<LLUUID, AssetBase> assets)
|
||||
{
|
||||
m_log.DebugFormat("[ARCHIVER]: Received all {0} textures required", assets.Count);
|
||||
|
||||
|
||||
// XXX: Shouldn't hijack the asset async callback thread like this - this is only temporary
|
||||
|
||||
|
||||
TarArchive archive = new TarArchive();
|
||||
|
||||
|
||||
archive.AddFile("prims.xml", m_serializedEntities);
|
||||
|
||||
|
||||
foreach (LLUUID uuid in assets.Keys)
|
||||
{
|
||||
archive.AddFile(uuid.ToString() + ".jp2", assets[uuid].Data);
|
||||
}
|
||||
|
||||
|
||||
archive.WriteTar(m_savePath);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get an xml representation of the given scene objects.
|
||||
/// </summary>
|
||||
@@ -152,38 +152,38 @@ namespace OpenSim.Region.Environment
|
||||
/// Callback used when all the assets requested have been received.
|
||||
/// </summary>
|
||||
protected AssetsRequestCallback m_assetsRequestCallback;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Assets retrieved in this request
|
||||
/// </summary>
|
||||
protected Dictionary<LLUUID, AssetBase> m_assets = new Dictionary<LLUUID, AssetBase>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Record the number of asset replies required so we know when we've finished
|
||||
/// </summary>
|
||||
private int m_repliesRequired;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Asset cache used to request the assets
|
||||
/// </summary>
|
||||
protected AssetCache m_assetCache;
|
||||
|
||||
protected internal AssetsRequest(AssetsRequestCallback assetsRequestCallback, AssetCache assetCache, ICollection<LLUUID> uuids)
|
||||
{
|
||||
m_assetsRequestCallback = assetsRequestCallback;
|
||||
protected AssetCache m_assetCache;
|
||||
|
||||
protected internal AssetsRequest(AssetsRequestCallback assetsRequestCallback, AssetCache assetCache, ICollection<LLUUID> uuids)
|
||||
{
|
||||
m_assetsRequestCallback = assetsRequestCallback;
|
||||
m_assetCache = assetCache;
|
||||
m_repliesRequired = uuids.Count;
|
||||
|
||||
|
||||
// We can stop here if there are no assets to fetch
|
||||
if (m_repliesRequired == 0)
|
||||
m_assetsRequestCallback(m_assets);
|
||||
|
||||
m_assetsRequestCallback(m_assets);
|
||||
|
||||
foreach (LLUUID uuid in uuids)
|
||||
{
|
||||
m_assetCache.GetAsset(uuid, AssetRequestCallback, true);
|
||||
m_assetCache.GetAsset(uuid, AssetRequestCallback, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Called back by the asset cache when it has the asset
|
||||
/// </summary>
|
||||
@@ -192,7 +192,7 @@ namespace OpenSim.Region.Environment
|
||||
public void AssetRequestCallback(LLUUID assetID, AssetBase asset)
|
||||
{
|
||||
m_assets[assetID] = asset;
|
||||
|
||||
|
||||
if (m_assets.Count == m_repliesRequired)
|
||||
{
|
||||
m_assetsRequestCallback(m_assets);
|
||||
|
||||
@@ -34,16 +34,16 @@ using System.Reflection;
|
||||
using log4net;
|
||||
|
||||
namespace OpenSim.Region.Environment
|
||||
{
|
||||
{
|
||||
/// <summary>
|
||||
/// Temporary code to produce a tar archive in tar v7 format
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public class TarArchive
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
||||
protected Dictionary<string, byte[]> m_files = new Dictionary<string, byte[]>();
|
||||
|
||||
|
||||
protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
|
||||
|
||||
/// <summary>
|
||||
@@ -55,7 +55,7 @@ namespace OpenSim.Region.Environment
|
||||
{
|
||||
AddFile(filePath, m_asciiEncoding.GetBytes(data));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add a file to the tar archive
|
||||
/// </summary>
|
||||
@@ -65,117 +65,117 @@ namespace OpenSim.Region.Environment
|
||||
{
|
||||
m_files[filePath] = data;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Write the raw tar archive data to a file
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public void WriteTar(string archivePath)
|
||||
{
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(archivePath, FileMode.Create));
|
||||
BinaryWriter bw = new BinaryWriter(new FileStream(archivePath, FileMode.Create));
|
||||
|
||||
foreach (string filePath in m_files.Keys)
|
||||
{
|
||||
byte[] header = new byte[512];
|
||||
byte[] data = m_files[filePath];
|
||||
|
||||
//string filePath = "test.txt";
|
||||
//byte[] data = m_asciiEncoding.GetBytes("hello\n");
|
||||
|
||||
|
||||
//string filePath = "test.txt";
|
||||
//byte[] data = m_asciiEncoding.GetBytes("hello\n");
|
||||
|
||||
// file path field (100)
|
||||
byte[] nameBytes = m_asciiEncoding.GetBytes(filePath);
|
||||
int nameSize = (nameBytes.Length >= 100) ? 100 : nameBytes.Length;
|
||||
Array.Copy(nameBytes, header, nameSize);
|
||||
|
||||
Array.Copy(nameBytes, header, nameSize);
|
||||
|
||||
// file mode (8)
|
||||
byte[] modeBytes = m_asciiEncoding.GetBytes("0000644");
|
||||
Array.Copy(modeBytes, 0, header, 100, 7);
|
||||
|
||||
|
||||
// owner user id (8)
|
||||
byte[] ownerIdBytes = m_asciiEncoding.GetBytes("0000764");
|
||||
Array.Copy(ownerIdBytes, 0, header, 108, 7);
|
||||
|
||||
|
||||
// group user id (8)
|
||||
byte[] groupIdBytes = m_asciiEncoding.GetBytes("0000764");
|
||||
Array.Copy(groupIdBytes, 0, header, 116, 7);
|
||||
|
||||
|
||||
// file size in bytes (12)
|
||||
int fileSize = data.Length;
|
||||
m_log.DebugFormat("[TAR ARCHIVE]: File size of {0} is {1}", filePath, fileSize);
|
||||
|
||||
byte[] fileSizeBytes = ConvertDecimalToPaddedOctalBytes(fileSize, 11);
|
||||
|
||||
|
||||
Array.Copy(fileSizeBytes, 0, header, 124, 11);
|
||||
|
||||
|
||||
// last modification time (12)
|
||||
byte[] lastModTimeBytes = m_asciiEncoding.GetBytes("11017037332");
|
||||
Array.Copy(lastModTimeBytes, 0, header, 136, 11);
|
||||
|
||||
Array.Copy(lastModTimeBytes, 0, header, 136, 11);
|
||||
|
||||
// link indicator (1)
|
||||
//header[156] = m_asciiEncoding.GetBytes("0")[0];
|
||||
header[156] = 0;
|
||||
|
||||
|
||||
Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 329, 7);
|
||||
Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 337, 7);
|
||||
|
||||
|
||||
// check sum for header block (8) [calculated last]
|
||||
Array.Copy(m_asciiEncoding.GetBytes(" "), 0, header, 148, 8);
|
||||
|
||||
|
||||
int checksum = 0;
|
||||
foreach (byte b in header)
|
||||
{
|
||||
checksum += b;
|
||||
}
|
||||
|
||||
|
||||
m_log.DebugFormat("[TAR ARCHIVE]: Decimal header checksum is {0}", checksum);
|
||||
|
||||
|
||||
byte[] checkSumBytes = ConvertDecimalToPaddedOctalBytes(checksum, 6);
|
||||
//byte[] checkSumBytes = m_asciiEncoding.GetBytes("007520");
|
||||
|
||||
|
||||
Array.Copy(checkSumBytes, 0, header, 148, 6);
|
||||
|
||||
|
||||
header[154] = 0;
|
||||
|
||||
// Write out header
|
||||
|
||||
// Write out header
|
||||
bw.Write(header);
|
||||
|
||||
|
||||
// Write out data
|
||||
bw.Write(data);
|
||||
|
||||
|
||||
int paddingRequired = 512 - (data.Length % 512);
|
||||
if (paddingRequired > 0)
|
||||
{
|
||||
m_log.DebugFormat("Padding data with {0} bytes", paddingRequired);
|
||||
|
||||
|
||||
byte[] padding = new byte[paddingRequired];
|
||||
bw.Write(padding);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write two consecutive 0 blocks to end the archive
|
||||
byte[] finalZeroPadding = new byte[1024];
|
||||
bw.Write(finalZeroPadding);
|
||||
|
||||
|
||||
bw.Close();
|
||||
}
|
||||
|
||||
|
||||
public static byte[] ConvertDecimalToPaddedOctalBytes(int d, int padding)
|
||||
{
|
||||
string oString = "";
|
||||
|
||||
string oString = "";
|
||||
|
||||
while (d > 0)
|
||||
{
|
||||
oString = Convert.ToString((byte)'0' + d & 7) + oString;
|
||||
d >>= 3;
|
||||
}
|
||||
|
||||
|
||||
while (oString.Length < padding)
|
||||
{
|
||||
oString = "0" + oString;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
byte[] oBytes = m_asciiEncoding.GetBytes(oString);
|
||||
|
||||
|
||||
return oBytes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
|
||||
double t = map[x, y];
|
||||
int index = 0;
|
||||
|
||||
// The lookup table is pre-sorted, so we either find an exact match or
|
||||
// The lookup table is pre-sorted, so we either find an exact match or
|
||||
// the next closest (smaller) match with a binary search
|
||||
index = Array.BinarySearch<HeightmapLookupValue>(LookupHeightTable, new HeightmapLookupValue(0, t));
|
||||
if (index < 0)
|
||||
|
||||
Reference in New Issue
Block a user