public IEnumerable <Edge <PositionalNode> > GetConnections(PositionalNode starting) { float[] newEndCoords; //Go through each edge that would normally be returned. foreach (Edge <PositionalNode> e in Wrapping.GetConnections(starting)) { newEndCoords = e.End.Coordinate.ToArray(); //If it's outside the X bounds, either wrap it or discard it. if (!RegionX.Inside(newEndCoords[0])) { if (WrapX) { newEndCoords[0] = RegionX.Wrap(newEndCoords[0]); } else { continue; } } //Do the same for the Y bounds. if (!RegionY.Inside(newEndCoords[1])) { if (WrapY) { newEndCoords[1] = RegionY.Wrap(newEndCoords[1]); } else { continue; } } //Return the value. yield return(new PositionalEdge(e.Start.Coordinate, newEndCoords, e.End.DecimalPlaces)); } }
private Packet InImprovedInstantMessageHandler(Packet packet, IPEndPoint sim) { if (RegionHandle != 0) { SoundTriggerPacket sound = new SoundTriggerPacket(); sound.SoundData.SoundID = new UUID("4c366008-65da-2e84-9b74-f58a392b94c6"); sound.SoundData.OwnerID = frame.AgentID; sound.SoundData.ObjectID = frame.AgentID; sound.SoundData.ParentID = UUID.Zero; sound.SoundData.Handle = RegionHandle; sound.SoundData.Position = CameraCenter; sound.SoundData.Gain = 0.5f; sound.Header.Reliable = false; if (!File.Exists("mutesound.on")) { proxy.InjectPacket(sound, Direction.Incoming); } } ImprovedInstantMessagePacket im = (ImprovedInstantMessagePacket)packet; //block repeated crap if (im.MessageBlock.Dialog == (byte)InstantMessageDialog.StartTyping) { if (PeopleWhoIMedMe.Contains(im.AgentData.AgentID) == false) { PeopleWhoIMedMe.Add(im.AgentData.AgentID); ImprovedInstantMessagePacket im2 = new ImprovedInstantMessagePacket(); im2.AgentData = new ImprovedInstantMessagePacket.AgentDataBlock(); im2.AgentData.AgentID = im.AgentData.AgentID; im2.AgentData.SessionID = im.AgentData.SessionID; im2.MessageBlock = new ImprovedInstantMessagePacket.MessageBlockBlock(); im2.MessageBlock.FromGroup = im.MessageBlock.FromGroup; im2.MessageBlock.ToAgentID = im.MessageBlock.ToAgentID; im2.MessageBlock.ParentEstateID = im.MessageBlock.ParentEstateID; im2.MessageBlock.RegionID = im.MessageBlock.RegionID; im2.MessageBlock.Position = im.MessageBlock.Position; im2.MessageBlock.Offline = im.MessageBlock.Offline; im2.MessageBlock.Dialog = 0; im2.MessageBlock.ID = im.MessageBlock.ID; im2.MessageBlock.Timestamp = im.MessageBlock.Timestamp; im2.MessageBlock.FromAgentName = im.MessageBlock.FromAgentName; im2.MessageBlock.Message = Utils.StringToBytes("/me is typing a message..."); im2.MessageBlock.BinaryBucket = im.MessageBlock.BinaryBucket; proxy.InjectPacket(im2, Direction.Incoming); } } else if (im.MessageBlock.Dialog == 22) // teleport lure { string[] bbfields = Utils.BytesToString(im.MessageBlock.BinaryBucket).Split('|'); if (bbfields.Length < 5) { return(packet); } ushort MapX; ushort MapY; double RegionX; double RegionY; double RegionZ; try { MapX = (ushort)(uint.Parse(bbfields[0]) / 256); MapY = (ushort)(uint.Parse(bbfields[1]) / 256); RegionX = double.Parse(bbfields[2]); RegionY = double.Parse(bbfields[3]); RegionZ = double.Parse(bbfields[4]); } catch { frame.SayToUser("WARNING! " + Utils.BytesToString(im.MessageBlock.FromAgentName) + "'s teleport lure IM seems to have unusual data in its BinaryBucket!"); return(packet); } // request region name System.Timers.Timer myTimer = new System.Timers.Timer(10000); string RegionName = null; PacketDelegate replyCallback = delegate(Packet p, IPEndPoint s) { MapBlockReplyPacket reply = (MapBlockReplyPacket)p; foreach (MapBlockReplyPacket.DataBlock block in reply.Data) { if ((block.X == MapX) && (block.Y == MapY)) { RegionName = Utils.BytesToString(block.Name); StringBuilder sb = new StringBuilder(); sb.Append(Utils.BytesToString(im.MessageBlock.FromAgentName) + "'s teleport lure is to "); sb.Append(RegionName + " " + RegionX.ToString() + ", " + RegionY.ToString() + ", " + RegionZ.ToString() + " "); sb.Append("secondlife://" + RegionName.Replace(" ", "%20") + "/" + RegionX.ToString() + "/" + RegionY.ToString() + "/" + RegionZ.ToString()); frame.SayToUser(sb.ToString()); } } return(null); }; System.Timers.ElapsedEventHandler timerCallback = delegate(object sender, System.Timers.ElapsedEventArgs e) { if (RegionName == null) { frame.SayToUser("Couldn't resolve the destination of " + Utils.BytesToString(im.MessageBlock.FromAgentName) + "'s teleport lure: " + Utils.BytesToString(im.MessageBlock.BinaryBucket)); } proxy.RemoveDelegate(PacketType.MapBlockReply, Direction.Incoming, replyCallback); myTimer.Stop(); }; proxy.AddDelegate(PacketType.MapBlockReply, Direction.Incoming, replyCallback); myTimer.Elapsed += timerCallback; myTimer.Start(); MapBlockRequestPacket MapBlockRequest = new MapBlockRequestPacket(); MapBlockRequest.AgentData = new MapBlockRequestPacket.AgentDataBlock(); MapBlockRequest.AgentData.AgentID = frame.AgentID; MapBlockRequest.AgentData.SessionID = frame.SessionID; MapBlockRequest.AgentData.Flags = 0; MapBlockRequest.AgentData.Godlike = false; MapBlockRequest.PositionData = new MapBlockRequestPacket.PositionDataBlock(); MapBlockRequest.PositionData.MinX = MapX; MapBlockRequest.PositionData.MaxX = MapX; MapBlockRequest.PositionData.MinY = MapY; MapBlockRequest.PositionData.MaxY = MapY; proxy.InjectPacket(MapBlockRequest, Direction.Outgoing); } else if (im.MessageBlock.Dialog == (byte)InstantMessageDialog.InventoryOffered) { if (im.MessageBlock.BinaryBucket[0] == (byte)AssetType.Simstate) { frame.SayToUser(Utils.BytesToString(im.MessageBlock.FromAgentName) + " offered you a SimState :O"); return(null); } } else if (im.MessageBlock.Dialog == 9) { if (im.MessageBlock.BinaryBucket[0] == (byte)AssetType.Simstate) { frame.SayToUser(im.AgentData.AgentID.ToString() + " offered you a SimState from an object at " + im.MessageBlock.Position.ToString() + " :O Message = " + Utils.BytesToString(im.MessageBlock.Message)); return(null); } } // Don't get spammed bro if (im.MessageBlock.Dialog == 0) { im.MessageBlock.ID = frame.AgentID.Equals(im.AgentData.AgentID) ? frame.AgentID : im.AgentData.AgentID ^ frame.AgentID; packet = (Packet)im; } return(packet); }