* Fixed SecondLife.GetAgentDetails to prevent it from registering multiple callbacks

* Added code documentation skeletons in SecondLife.cs
* Removed Helpers.Log and replaced it with SecondLife.Log that is silent if SecondLife.Debug = false;
* Removed logging from ProtocolManager.cs where an exception was also being thrown
* Replaced logging in the FieldToString method with a sensible return value on error
* Replaced Packet.Blocks() logging with an ugly hack for now
* Replaced most logging with exception throwing to prevent broken apps from breaking further
* Formatting fixes for some of the files

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@173 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
John Hurliman
2006-09-07 03:39:23 +00:00
parent 34c4f2bb71
commit bf19f1bc2a
8 changed files with 1335 additions and 1345 deletions

View File

@@ -39,9 +39,9 @@ namespace libsecondlife
public class MapField : IComparable
{
public int KeywordPosition;
public string Name;
public FieldType Type;
public int KeywordPosition;
public string Name;
public FieldType Type;
public int Count;
public int CompareTo(object obj)
@@ -68,9 +68,9 @@ namespace libsecondlife
public class MapBlock : IComparable
{
public int KeywordPosition;
public string Name;
public int Count;
public int KeywordPosition;
public string Name;
public int Count;
public ArrayList Fields;
public int CompareTo(object obj)
@@ -112,10 +112,14 @@ namespace libsecondlife
public MapPacket[] LowMaps;
public MapPacket[] MediumMaps;
public MapPacket[] HighMaps;
int i = 0;
public ProtocolManager(string keywordFile, string mapFile)
private SecondLife Client;
private int i = 0;
public ProtocolManager(string keywordFile, string mapFile, SecondLife client)
{
Client = client;
// Initialize the map arrays
LowMaps = new MapPacket[65536];
MediumMaps = new MapPacket[256];
@@ -194,13 +198,13 @@ namespace libsecondlife
throw new Exception("Cannot find map for command \"" + command + "\"");
}
public MapPacket Command(byte[] data)
{
public MapPacket Command(byte[] data)
{
ushort command;
if (data.Length < 5)
{
return null;
return null;
}
if (data[4] == 0xFF)
@@ -209,22 +213,22 @@ namespace libsecondlife
{
// Low frequency
command = (ushort)(data[6] * 256 + data[7]);
return Command(command, PacketFrequency.Low);
return Command(command, PacketFrequency.Low);
}
else
{
// Medium frequency
command = (ushort)data[5];
return Command(command, PacketFrequency.Medium);
return Command(command, PacketFrequency.Medium);
}
}
else
{
// High frequency
command = (ushort)data[4];
return Command(command, PacketFrequency.High);
}
}
return Command(command, PacketFrequency.High);
}
}
public MapPacket Command(ushort command, PacketFrequency frequency)
{
@@ -294,7 +298,7 @@ namespace libsecondlife
}
catch(Exception e)
{
Helpers.Log("Error opening \"" + keywordFile + "\": " + e.Message, Helpers.LogLevel.Error);
Client.Log("Error opening \"" + keywordFile + "\": " + e.Message, Helpers.LogLevel.Error);
throw new Exception("Keyword file error", e);
}
@@ -320,7 +324,6 @@ namespace libsecondlife
}
catch(Exception e)
{
Helpers.Log("Error opening \"" + mapFile + "\": " + e.Message, Helpers.LogLevel.Error);
throw new Exception("Map file error", e);
}
@@ -330,7 +333,6 @@ namespace libsecondlife
}
catch(Exception e)
{
Helpers.Log("Error opening \"" + outputFile + "\": " + e.Message, Helpers.LogLevel.Error);
throw new Exception("Map file error", e);
}
@@ -363,7 +365,6 @@ namespace libsecondlife
}
catch(Exception e)
{
Helpers.Log("Error opening \"" + mapFile + "\": " + e.Message, Helpers.LogLevel.Error);
throw new Exception("Map file error", e);
}
@@ -490,7 +491,7 @@ namespace libsecondlife
}
else
{
Helpers.Log("!!!", Helpers.LogLevel.Error);
Client.Log("Unknown packet frequency", Helpers.LogLevel.Error);
}
}
@@ -561,7 +562,7 @@ namespace libsecondlife
}
else
{
Helpers.Log("Unknown block frequency!", Helpers.LogLevel.Error);
Client.Log("Unknown block frequency", Helpers.LogLevel.Error);
}
#endregion
@@ -577,7 +578,7 @@ namespace libsecondlife
}
catch (Exception e)
{
Helpers.Log(e.ToString(), Helpers.LogLevel.Error);
throw e;
}
}
@@ -589,9 +590,9 @@ namespace libsecondlife
}
else
{
Helpers.Log("Couldn't find keyword: " + keyword, Helpers.LogLevel.Warning);
Client.Log("Couldn't find keyword: " + keyword, Helpers.LogLevel.Warning);
return -1;
}
}
}
}
}