aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/ClientView.Grid.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/OpenSim.RegionServer/ClientView.Grid.cs')
-rw-r--r--OpenSim/OpenSim.RegionServer/ClientView.Grid.cs157
1 files changed, 157 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.RegionServer/ClientView.Grid.cs b/OpenSim/OpenSim.RegionServer/ClientView.Grid.cs
new file mode 100644
index 0000000..a3b191c
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/ClientView.Grid.cs
@@ -0,0 +1,157 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using libsecondlife;
5using libsecondlife.Packets;
6using Nwc.XmlRpc;
7using System.Net;
8using System.Net.Sockets;
9using System.IO;
10using System.Threading;
11using System.Timers;
12using OpenSim.Framework.Interfaces;
13using OpenSim.Framework.Types;
14using OpenSim.Framework.Inventory;
15using OpenSim.Framework.Utilities;
16using OpenSim.world;
17using OpenSim.Assets;
18
19namespace OpenSim
20{
21 public partial class ClientView
22 {
23
24 public void EnableNeighbours()
25 {
26 if ((this.m_gridServer.GetName() == "Remote") && (!this.m_child))
27 {
28 Hashtable SimParams;
29 ArrayList SendParams;
30 XmlRpcRequest GridReq;
31 XmlRpcResponse GridResp;
32 List<Packet> enablePackets = new List<Packet>();
33
34 RemoteGridBase gridServer = (RemoteGridBase)this.m_gridServer;
35
36 foreach (Hashtable neighbour in gridServer.neighbours)
37 {
38 string neighbourIPStr = (string)neighbour["sim_ip"];
39 System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse(neighbourIPStr);
40 ushort neighbourPort = (ushort)Convert.ToInt32(neighbour["sim_port"]);
41 string reqUrl = "http://" + neighbourIPStr + ":" + neighbourPort.ToString();
42
43 Console.WriteLine(reqUrl);
44
45 SimParams = new Hashtable();
46 SimParams["session_id"] = this.SessionID.ToString();
47 SimParams["secure_session_id"] = this.SecureSessionID.ToString();
48 SimParams["firstname"] = this.ClientAvatar.firstname;
49 SimParams["lastname"] = this.ClientAvatar.lastname;
50 SimParams["agent_id"] = this.AgentID.ToString();
51 SimParams["circuit_code"] = (Int32)this.CircuitCode;
52 SimParams["child_agent"] = "1";
53 SendParams = new ArrayList();
54 SendParams.Add(SimParams);
55
56 GridReq = new XmlRpcRequest("expect_user", SendParams);
57 GridResp = GridReq.Send(reqUrl, 3000);
58 EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket();
59 enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
60 enablesimpacket.SimulatorInfo.Handle = Helpers.UIntsToLong((uint)(Convert.ToInt32(neighbour["region_locx"]) * 256), (uint)(Convert.ToInt32(neighbour["region_locy"]) * 256));
61
62
63 byte[] byteIP = neighbourIP.GetAddressBytes();
64 enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
65 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
66 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
67 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
68 enablesimpacket.SimulatorInfo.Port = neighbourPort;
69 enablePackets.Add(enablesimpacket);
70 }
71 Thread.Sleep(3000);
72 foreach (Packet enable in enablePackets)
73 {
74 this.OutPacket(enable);
75 }
76 enablePackets.Clear();
77
78 }
79 }
80
81 public void CrossSimBorder(LLVector3 avatarpos)
82 { // VERY VERY BASIC
83
84 LLVector3 newpos = avatarpos;
85 uint neighbourx = this.m_regionData.RegionLocX;
86 uint neighboury = this.m_regionData.RegionLocY;
87
88 if (avatarpos.X < 0)
89 {
90 neighbourx -= 1;
91 newpos.X = 254;
92 }
93 if (avatarpos.X > 255)
94 {
95 neighbourx += 1;
96 newpos.X = 1;
97 }
98 if (avatarpos.Y < 0)
99 {
100 neighboury -= 1;
101 newpos.Y = 254;
102 }
103 if (avatarpos.Y > 255)
104 {
105 neighboury += 1;
106 newpos.Y = 1;
107 }
108 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:CrossSimBorder() - Crossing border to neighbouring sim at [" + neighbourx.ToString() + "," + neighboury.ToString() + "]");
109
110 Hashtable SimParams;
111 ArrayList SendParams;
112 XmlRpcRequest GridReq;
113 XmlRpcResponse GridResp;
114 foreach (Hashtable borderingSim in ((RemoteGridBase)m_gridServer).neighbours)
115 {
116 if (((string)borderingSim["region_locx"]).Equals(neighbourx.ToString()) && ((string)borderingSim["region_locy"]).Equals(neighboury.ToString()))
117 {
118 SimParams = new Hashtable();
119 SimParams["firstname"] = this.ClientAvatar.firstname;
120 SimParams["lastname"] = this.ClientAvatar.lastname;
121 SimParams["circuit_code"] = this.CircuitCode.ToString();
122 SimParams["pos_x"] = newpos.X.ToString();
123 SimParams["pos_y"] = newpos.Y.ToString();
124 SimParams["pos_z"] = newpos.Z.ToString();
125 SendParams = new ArrayList();
126 SendParams.Add(SimParams);
127
128 GridReq = new XmlRpcRequest("agent_crossing", SendParams);
129 GridResp = GridReq.Send("http://" + borderingSim["sim_ip"] + ":" + borderingSim["sim_port"], 3000);
130
131 CrossedRegionPacket NewSimPack = new CrossedRegionPacket();
132 NewSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
133 NewSimPack.AgentData.AgentID = this.AgentID;
134 NewSimPack.AgentData.SessionID = this.SessionID;
135 NewSimPack.Info = new CrossedRegionPacket.InfoBlock();
136 NewSimPack.Info.Position = newpos;
137 NewSimPack.Info.LookAt = new LLVector3(0.99f, 0.042f, 0); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!!
138 NewSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock();
139 NewSimPack.RegionData.RegionHandle = Helpers.UIntsToLong((uint)(Convert.ToInt32(borderingSim["region_locx"]) * 256), (uint)(Convert.ToInt32(borderingSim["region_locy"]) * 256));
140 System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)borderingSim["sim_ip"]);
141 byte[] byteIP = neighbourIP.GetAddressBytes();
142 NewSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
143 NewSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
144 NewSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
145 NewSimPack.RegionData.SimIP += (uint)byteIP[0];
146 NewSimPack.RegionData.SimPort = (ushort)Convert.ToInt32(borderingSim["sim_port"]);
147 NewSimPack.RegionData.SeedCapability = new byte[0];
148 lock (PacketQueue)
149 {
150 ProcessOutPacket(NewSimPack);
151 DowngradeClient();
152 }
153 }
154 }
155 }
156 }
157}