TryGetValue() for a nice time
This commit is contained in:
@@ -552,14 +552,14 @@ namespace GridProxy
|
||||
headers[key.ToLower()] = val;
|
||||
} while (line != "");
|
||||
|
||||
if (headers.ContainsKey("content-length"))
|
||||
if (headers.TryGetValue("content-length", out var length))
|
||||
{
|
||||
contentLength = Convert.ToInt32(headers["content-length"]);
|
||||
contentLength = Convert.ToInt32(length);
|
||||
}
|
||||
|
||||
if (headers.ContainsKey("content-type"))
|
||||
if (headers.TryGetValue("content-type", out var type))
|
||||
{
|
||||
contentType = headers["content-type"];
|
||||
contentType = type;
|
||||
}
|
||||
|
||||
// read the HTTP body into a buffer
|
||||
@@ -1322,10 +1322,10 @@ namespace GridProxy
|
||||
bool needsCopy = true;
|
||||
var length = simFacingSocket.EndReceiveFrom(ar, ref remoteEndPoint);
|
||||
|
||||
if (proxyHandlers.ContainsKey(remoteEndPoint))
|
||||
if (proxyHandlers.TryGetValue(remoteEndPoint, out var handler))
|
||||
{
|
||||
// find the proxy responsible for forwarding this packet
|
||||
SimProxy simProxy = (SimProxy)proxyHandlers[remoteEndPoint];
|
||||
SimProxy simProxy = handler;
|
||||
|
||||
// interpret the packet according to the SL protocol
|
||||
int end = length - 1;
|
||||
@@ -1344,7 +1344,7 @@ namespace GridProxy
|
||||
simProxy.incomingSequence = packet.Header.Sequence;
|
||||
|
||||
// check the packet for addresses that need proxying
|
||||
if (incomingCheckers.ContainsKey(packet.Type))
|
||||
if (incomingCheckers.TryGetValue(packet.Type, out var checker))
|
||||
{
|
||||
/* if (needsZero) {
|
||||
length = Helpers.ZeroDecode(packet.Header.Data, length, zeroBuffer);
|
||||
@@ -1352,7 +1352,7 @@ namespace GridProxy
|
||||
needsZero = false;
|
||||
} */
|
||||
|
||||
Packet newPacket = ((AddressChecker)incomingCheckers[packet.Type])(packet);
|
||||
Packet newPacket = ((AddressChecker)checker)(packet);
|
||||
SwapPacket(packet, newPacket);
|
||||
packet = newPacket;
|
||||
needsCopy = false;
|
||||
@@ -1496,9 +1496,9 @@ namespace GridProxy
|
||||
// ProxySim: return the proxy for the specified sim, creating it if it doesn't exist
|
||||
private IPEndPoint ProxySim(IPEndPoint simEndPoint)
|
||||
{
|
||||
if (proxyEndPoints.ContainsKey(simEndPoint))
|
||||
if (proxyEndPoints.TryGetValue(simEndPoint, out var point))
|
||||
// return the existing proxy
|
||||
return (IPEndPoint)proxyEndPoints[simEndPoint];
|
||||
return point;
|
||||
else
|
||||
{
|
||||
// return a new proxy
|
||||
@@ -1683,7 +1683,7 @@ namespace GridProxy
|
||||
outgoingSequence = packet.Header.Sequence;
|
||||
|
||||
// check the packet for addresses that need proxying
|
||||
if (proxy.outgoingCheckers.ContainsKey(packet.Type))
|
||||
if (proxy.outgoingCheckers.TryGetValue(packet.Type, out var checker))
|
||||
{
|
||||
/* if (packet.Header.Zerocoded) {
|
||||
length = Helpers.ZeroDecode(packet.Header.Data, length, zeroBuffer);
|
||||
@@ -1691,7 +1691,7 @@ namespace GridProxy
|
||||
needsZero = false;
|
||||
} */
|
||||
|
||||
Packet newPacket = ((AddressChecker)proxy.outgoingCheckers[packet.Type])(packet);
|
||||
Packet newPacket = ((AddressChecker)checker)(packet);
|
||||
SwapPacket(packet, newPacket);
|
||||
packet = newPacket;
|
||||
needsCopy = false;
|
||||
|
||||
@@ -206,7 +206,7 @@ public class Analyst : ProxyPlugin
|
||||
|
||||
string[] valueArray = new string[words.Length - 4];
|
||||
Array.Copy(words, 4, valueArray, 0, words.Length - 4);
|
||||
string valueString = String.Join(" ", valueArray);
|
||||
string valueString = string.Join(" ", valueArray);
|
||||
object value;
|
||||
try
|
||||
{
|
||||
@@ -218,11 +218,8 @@ public class Analyst : ProxyPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
Dictionary<BlockField, object> fields;
|
||||
if (modifiedPackets.ContainsKey(pType))
|
||||
fields = (Dictionary<BlockField, object>)modifiedPackets[pType];
|
||||
else
|
||||
fields = new Dictionary<BlockField, object>();
|
||||
var fields = modifiedPackets.TryGetValue(pType, out var packet)
|
||||
? packet : new Dictionary<BlockField, object>();
|
||||
|
||||
fields[new BlockField(words[2], words[3])] = value;
|
||||
modifiedPackets[pType] = fields;
|
||||
@@ -626,11 +623,10 @@ public class Analyst : ProxyPlugin
|
||||
// Modify: modify a packet
|
||||
private Packet Modify(Packet packet, IPEndPoint endPoint, Direction direction)
|
||||
{
|
||||
if (modifiedPackets.ContainsKey(packet.Type))
|
||||
if (modifiedPackets.TryGetValue(packet.Type, out var changes))
|
||||
{
|
||||
try
|
||||
{
|
||||
Dictionary<BlockField, object> changes = modifiedPackets[packet.Type];
|
||||
Type packetClass = packet.GetType();
|
||||
|
||||
foreach (KeyValuePair<BlockField, object> change in changes)
|
||||
|
||||
@@ -652,9 +652,9 @@ public class ClientAO : ProxyPlugin
|
||||
//SayToUser("anim: " + animname);
|
||||
if (animname != "")
|
||||
{
|
||||
if (currentFolderItems.ContainsKey(animname))
|
||||
if (currentFolderItems.TryGetValue(animname, out var item))
|
||||
{
|
||||
UUID over = currentFolderItems[animname].AssetUUID;
|
||||
UUID over = item.AssetUUID;
|
||||
UUID orig = wetikonanims[((i + 1) / 2) - 1];
|
||||
//put it in overrides
|
||||
animuid2name[over] = animname;
|
||||
|
||||
@@ -48,9 +48,9 @@ namespace OpenMetaverse.TestClient
|
||||
else if (arg.ToLower().Equals("show"))
|
||||
{
|
||||
Client.Self.SignaledAnimations.ForEach(delegate(KeyValuePair<UUID, int> kvp) {
|
||||
if (m_BuiltInAnimations.ContainsKey(kvp.Key))
|
||||
if (m_BuiltInAnimations.TryGetValue(kvp.Key, out var animation))
|
||||
{
|
||||
result.AppendFormat("The {0} System Animation is being played, sequence is {1}", m_BuiltInAnimations[kvp.Key], kvp.Value);
|
||||
result.AppendFormat("The {0} System Animation is being played, sequence is {1}", animation, kvp.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -72,8 +72,8 @@ namespace OpenMetaverse.TestClient
|
||||
{
|
||||
if (prim.ParentID == 0)
|
||||
{
|
||||
if (linksets.ContainsKey(prim.LocalID))
|
||||
linksets[prim.LocalID].RootPrim = prim;
|
||||
if (linksets.TryGetValue(prim.LocalID, out var linkset))
|
||||
linkset.RootPrim = prim;
|
||||
else
|
||||
linksets[prim.LocalID] = new Linkset(prim);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user