diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim.RegionServer/SimClient.cs | 114 |
1 files changed, 107 insertions, 7 deletions
diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/SimClient.cs index c478d92..083ca68 100644 --- a/OpenSim.RegionServer/SimClient.cs +++ b/OpenSim.RegionServer/SimClient.cs | |||
@@ -29,6 +29,7 @@ using System.Collections; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using libsecondlife; | 30 | using libsecondlife; |
31 | using libsecondlife.Packets; | 31 | using libsecondlife.Packets; |
32 | using Nwc.XmlRpc; | ||
32 | using System.Net; | 33 | using System.Net; |
33 | using System.Net.Sockets; | 34 | using System.Net.Sockets; |
34 | using System.IO; | 35 | using System.IO; |
@@ -58,8 +59,9 @@ namespace OpenSim | |||
58 | public uint CircuitCode; | 59 | public uint CircuitCode; |
59 | public world.Avatar ClientAvatar; | 60 | public world.Avatar ClientAvatar; |
60 | private UseCircuitCodePacket cirpack; | 61 | private UseCircuitCodePacket cirpack; |
61 | private Thread ClientThread; | 62 | public Thread ClientThread; |
62 | public EndPoint userEP; | 63 | public EndPoint userEP; |
64 | public LLVector3 startpos; | ||
63 | private BlockingQueue<QueItem> PacketQueue; | 65 | private BlockingQueue<QueItem> PacketQueue; |
64 | private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); | 66 | private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); |
65 | private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); | 67 | private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); |
@@ -109,6 +111,11 @@ namespace OpenSim | |||
109 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request"); | 111 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request"); |
110 | cirpack = initialcirpack; | 112 | cirpack = initialcirpack; |
111 | userEP = remoteEP; | 113 | userEP = remoteEP; |
114 | if(m_gridServer.GetName() == "Remote") { | ||
115 | this.startpos=((RemoteGridBase)m_gridServer).agentcircuits[initialcirpack.CircuitCode.Code].startpos; | ||
116 | } else { | ||
117 | this.startpos=new LLVector3(128.0f,128.0f,60f); | ||
118 | } | ||
112 | PacketQueue = new BlockingQueue<QueItem>(); | 119 | PacketQueue = new BlockingQueue<QueItem>(); |
113 | 120 | ||
114 | this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); | 121 | this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); |
@@ -130,6 +137,100 @@ namespace OpenSim | |||
130 | this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate); | 137 | this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate); |
131 | } | 138 | } |
132 | 139 | ||
140 | public void CrossSimBorder(LLVector3 avatarpos) { // VERY VERY BASIC | ||
141 | LLVector3 newpos = avatarpos; | ||
142 | uint neighbourx=((OpenSimMain)m_application).regionData.RegionLocX; | ||
143 | uint neighboury=((OpenSimMain)m_application).regionData.RegionLocY; | ||
144 | |||
145 | if(avatarpos.X<0) { | ||
146 | neighbourx-=1; | ||
147 | newpos.X=0; | ||
148 | } | ||
149 | if(avatarpos.X>255) { | ||
150 | neighbourx+=1; | ||
151 | newpos.X=255; | ||
152 | } | ||
153 | if(avatarpos.Y<0) { | ||
154 | neighboury-=1; | ||
155 | newpos.Y=0; | ||
156 | } | ||
157 | if(avatarpos.Y>255) { | ||
158 | neighbourx+=1; | ||
159 | newpos.Y=255; | ||
160 | } | ||
161 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimClient.cs:CrossSimBorder() - Crossing border to neighbouring sim at [" + neighbourx.ToString() + "," + neighboury.ToString() + "]"); | ||
162 | |||
163 | Hashtable SimParams; | ||
164 | ArrayList SendParams; | ||
165 | XmlRpcRequest GridReq; | ||
166 | XmlRpcResponse GridResp; | ||
167 | foreach(Hashtable borderingSim in ((RemoteGridBase)m_gridServer).neighbours) { | ||
168 | if(((string)borderingSim["region_locx"]).Equals(neighbourx.ToString()) && ((string)borderingSim["region_locy"]).Equals(neighboury.ToString())) { | ||
169 | CrossedRegionPacket NewSimPack = new CrossedRegionPacket(); | ||
170 | NewSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock(); | ||
171 | NewSimPack.AgentData.AgentID=this.AgentID; | ||
172 | NewSimPack.AgentData.SessionID=this.SessionID; | ||
173 | NewSimPack.Info = new CrossedRegionPacket.InfoBlock(); | ||
174 | NewSimPack.Info.Position=newpos; | ||
175 | NewSimPack.Info.LookAt=new LLVector3(0.99f, 0.042f, 0); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! | ||
176 | NewSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock(); | ||
177 | NewSimPack.RegionData.RegionHandle=Helpers.UIntsToLong((uint)(Convert.ToInt32(borderingSim["region_locx"]) * 256), (uint)(Convert.ToInt32(borderingSim["region_locy"]) * 256)); | ||
178 | |||
179 | System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)borderingSim["sim_ip"]); | ||
180 | byte[] byteIP = neighbourIP.GetAddressBytes(); | ||
181 | NewSimPack.RegionData.SimIP = (uint)byteIP[3] << 24; | ||
182 | NewSimPack.RegionData.SimIP += (uint)byteIP[2] << 16; | ||
183 | NewSimPack.RegionData.SimIP += (uint)byteIP[1] << 8; | ||
184 | NewSimPack.RegionData.SimIP += (uint)byteIP[0]; | ||
185 | NewSimPack.RegionData.SimPort = (ushort)Convert.ToInt32(borderingSim["sim_port"]); | ||
186 | NewSimPack.RegionData.SeedCapability = new byte[0]; | ||
187 | lock(PacketQueue) { | ||
188 | ProcessOutPacket(NewSimPack); | ||
189 | DowngradeClient(); | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | |||
195 | public void UpgradeClient() { | ||
196 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimClient.cs:UpgradeClient() - upgrading child to full agent"); | ||
197 | this.m_child=false; | ||
198 | this.m_world.RemoveViewerAgent(this); | ||
199 | this.InitNewClient(); | ||
200 | } | ||
201 | |||
202 | public void DowngradeClient() { | ||
203 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimClient.cs:UpgradeClient() - changing full agent to child"); | ||
204 | this.m_child=true; | ||
205 | this.m_world.RemoveViewerAgent(this); | ||
206 | this.m_world.AddViewerAgent(this); | ||
207 | } | ||
208 | |||
209 | public void KillClient() { | ||
210 | KillObjectPacket kill = new KillObjectPacket(); | ||
211 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | ||
212 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | ||
213 | kill.ObjectData[0].ID = this.ClientAvatar.localid; | ||
214 | foreach (SimClient client in m_clientThreads.Values) | ||
215 | { | ||
216 | client.OutPacket(kill); | ||
217 | } | ||
218 | if (this.m_userServer != null) | ||
219 | { | ||
220 | this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer); | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | this.m_inventoryCache.ClientLeaving(this.AgentID, null); | ||
225 | } | ||
226 | |||
227 | m_world.RemoveViewerAgent(this); | ||
228 | |||
229 | m_clientThreads.Remove(this.CircuitCode); | ||
230 | m_application.RemoveClientCircuit(this.CircuitCode); | ||
231 | this.ClientThread.Abort(); | ||
232 | } | ||
233 | |||
133 | public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) | 234 | public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) |
134 | { | 235 | { |
135 | bool result = false; | 236 | bool result = false; |
@@ -230,10 +331,9 @@ namespace OpenSim | |||
230 | switch (Pack.Type) | 331 | switch (Pack.Type) |
231 | { | 332 | { |
232 | case PacketType.CompleteAgentMovement: | 333 | case PacketType.CompleteAgentMovement: |
233 | if(!m_child) { | 334 | if(this.m_child) this.UpgradeClient(); |
234 | ClientAvatar.CompleteMovement(m_world); | 335 | ClientAvatar.CompleteMovement(m_world); |
235 | ClientAvatar.SendInitialPosition(); | 336 | ClientAvatar.SendInitialPosition(); |
236 | } | ||
237 | break; | 337 | break; |
238 | case PacketType.RegionHandshakeReply: | 338 | case PacketType.RegionHandshakeReply: |
239 | m_world.SendLayerData(this); | 339 | m_world.SendLayerData(this); |
@@ -797,7 +897,7 @@ namespace OpenSim | |||
797 | } | 897 | } |
798 | } | 898 | } |
799 | #region Packet handlers | 899 | #region Packet handlers |
800 | 900 | ||
801 | protected virtual bool Logout(SimClient simClient, Packet packet) | 901 | protected virtual bool Logout(SimClient simClient, Packet packet) |
802 | { | 902 | { |
803 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request"); | 903 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request"); |