aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/ClientView.Grid.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/OpenSim.RegionServer/ClientView.Grid.cs167
1 files changed, 167 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..1121839
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/ClientView.Grid.cs
@@ -0,0 +1,167 @@
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 try
39 {
40 string neighbourIPStr = (string)neighbour["sim_ip"];
41 System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse(neighbourIPStr);
42 ushort neighbourPort = (ushort)Convert.ToInt32(neighbour["sim_port"]);
43 string reqUrl = "http://" + neighbourIPStr + ":" + neighbourPort.ToString();
44
45 Console.WriteLine(reqUrl);
46
47 SimParams = new Hashtable();
48 SimParams["session_id"] = this.SessionID.ToString();
49 SimParams["secure_session_id"] = this.SecureSessionID.ToString();
50 SimParams["firstname"] = this.ClientAvatar.firstname;
51 SimParams["lastname"] = this.ClientAvatar.lastname;
52 SimParams["agent_id"] = this.AgentID.ToString();
53 SimParams["circuit_code"] = (Int32)this.CircuitCode;
54 SimParams["child_agent"] = "1";
55 SendParams = new ArrayList();
56 SendParams.Add(SimParams);
57
58 GridReq = new XmlRpcRequest("expect_user", SendParams);
59 GridResp = GridReq.Send(reqUrl, 3000);
60 EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket();
61 enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
62 enablesimpacket.SimulatorInfo.Handle = Helpers.UIntsToLong((uint)(Convert.ToInt32(neighbour["region_locx"]) * 256), (uint)(Convert.ToInt32(neighbour["region_locy"]) * 256));
63
64
65 byte[] byteIP = neighbourIP.GetAddressBytes();
66 enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
67 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
68 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
69 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
70 enablesimpacket.SimulatorInfo.Port = neighbourPort;
71 enablePackets.Add(enablesimpacket);
72 }
73 catch (Exception e)
74 {
75 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Could not connect to neighbour " + neighbour["sim_ip"] + ":" + neighbour["sim_port"] + ", continuing.");
76 }
77 }
78 Thread.Sleep(3000);
79 foreach (Packet enable in enablePackets)
80 {
81 this.OutPacket(enable);
82 }
83 enablePackets.Clear();
84
85 }
86 }
87
88 public void CrossSimBorder(LLVector3 avatarpos)
89 { // VERY VERY BASIC
90
91 LLVector3 newpos = avatarpos;
92 uint neighbourx = this.m_regionData.RegionLocX;
93 uint neighboury = this.m_regionData.RegionLocY;
94
95 if (avatarpos.X < 0)
96 {
97 neighbourx -= 1;
98 newpos.X = 254;
99 }
100 if (avatarpos.X > 255)
101 {
102 neighbourx += 1;
103 newpos.X = 1;
104 }
105 if (avatarpos.Y < 0)
106 {
107 neighboury -= 1;
108 newpos.Y = 254;
109 }
110 if (avatarpos.Y > 255)
111 {
112 neighboury += 1;
113 newpos.Y = 1;
114 }
115 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:CrossSimBorder() - Crossing border to neighbouring sim at [" + neighbourx.ToString() + "," + neighboury.ToString() + "]");
116
117 Hashtable SimParams;
118 ArrayList SendParams;
119 XmlRpcRequest GridReq;
120 XmlRpcResponse GridResp;
121 foreach (Hashtable borderingSim in ((RemoteGridBase)m_gridServer).neighbours)
122 {
123 if (((string)borderingSim["region_locx"]).Equals(neighbourx.ToString()) && ((string)borderingSim["region_locy"]).Equals(neighboury.ToString()))
124 {
125 Console.WriteLine("found the neighbouring sim");
126 SimParams = new Hashtable();
127 SimParams["firstname"] = this.ClientAvatar.firstname;
128 SimParams["lastname"] = this.ClientAvatar.lastname;
129 SimParams["circuit_code"] = this.CircuitCode.ToString();
130 SimParams["pos_x"] = newpos.X.ToString();
131 SimParams["pos_y"] = newpos.Y.ToString();
132 SimParams["pos_z"] = newpos.Z.ToString();
133 SendParams = new ArrayList();
134 SendParams.Add(SimParams);
135
136 GridReq = new XmlRpcRequest("agent_crossing", SendParams);
137 GridResp = GridReq.Send("http://" + borderingSim["sim_ip"] + ":" + borderingSim["sim_port"], 3000);
138
139 CrossedRegionPacket NewSimPack = new CrossedRegionPacket();
140 NewSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
141 NewSimPack.AgentData.AgentID = this.AgentID;
142 NewSimPack.AgentData.SessionID = this.SessionID;
143 NewSimPack.Info = new CrossedRegionPacket.InfoBlock();
144 NewSimPack.Info.Position = newpos;
145 NewSimPack.Info.LookAt = new LLVector3(0.99f, 0.042f, 0); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!!
146 NewSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock();
147 NewSimPack.RegionData.RegionHandle = Helpers.UIntsToLong((uint)(Convert.ToInt32(borderingSim["region_locx"]) * 256), (uint)(Convert.ToInt32(borderingSim["region_locy"]) * 256));
148 System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)borderingSim["sim_ip"]);
149 byte[] byteIP = neighbourIP.GetAddressBytes();
150 NewSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
151 NewSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
152 NewSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
153 NewSimPack.RegionData.SimIP += (uint)byteIP[0];
154 NewSimPack.RegionData.SimPort = (ushort)Convert.ToInt32(borderingSim["sim_port"]);
155 NewSimPack.RegionData.SeedCapability = new byte[0];
156 this.OutPacket(NewSimPack);
157 this.DowngradeClient();
158 /* lock (PacketQueue)
159 {
160 ProcessOutPacket(NewSimPack);
161 DowngradeClient();
162 }*/
163 }
164 }
165 }
166 }
167}