aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim.RegionServer')
-rw-r--r--OpenSim.RegionServer/OpenSimMain.cs23
-rw-r--r--OpenSim.RegionServer/SimClient.cs114
-rw-r--r--OpenSim.RegionServer/world/Avatar.cs4
-rw-r--r--OpenSim.RegionServer/world/AvatarUpdate.cs19
4 files changed, 142 insertions, 18 deletions
diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs
index 2492ee2..038c7e6 100644
--- a/OpenSim.RegionServer/OpenSimMain.cs
+++ b/OpenSim.RegionServer/OpenSimMain.cs
@@ -67,7 +67,7 @@ namespace OpenSim
67 //private Dictionary<uint, SimClient> ClientThreads = new Dictionary<uint, SimClient>(); 67 //private Dictionary<uint, SimClient> ClientThreads = new Dictionary<uint, SimClient>();
68 private Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); 68 private Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
69 private DateTime startuptime; 69 private DateTime startuptime;
70 private RegionInfo regionData; 70 public RegionInfo regionData;
71 71
72 public Socket Server; 72 public Socket Server;
73 private IPEndPoint ServerIncoming; 73 private IPEndPoint ServerIncoming;
@@ -206,12 +206,19 @@ namespace OpenSim
206 agent_data.firstname = (string)requestData["firstname"]; 206 agent_data.firstname = (string)requestData["firstname"];
207 agent_data.lastname = (string)requestData["lastname"]; 207 agent_data.lastname = (string)requestData["lastname"];
208 agent_data.AgentID = new LLUUID((string)requestData["agent_id"]); 208 agent_data.AgentID = new LLUUID((string)requestData["agent_id"]);
209 agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); 209 agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
210 if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1")) 210 if(requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1")) {
211 { 211 agent_data.child=true;
212 agent_data.child = true; 212 } else {
213 } 213 agent_data.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]),Convert.ToUInt32(requestData["startpos_y"]),Convert.ToUInt32(requestData["startpos_z"]));
214 ((RemoteGridBase)gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data); 214 agent_data.child=false;
215 }
216
217 if(((RemoteGridBase)gridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode)) {
218 ((RemoteGridBase)gridServer).agentcircuits[(uint)agent_data.circuitcode]=agent_data;
219 } else {
220 ((RemoteGridBase)gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data);
221 }
215 222
216 return new XmlRpcResponse(); 223 return new XmlRpcResponse();
217 }); 224 });
@@ -286,7 +293,7 @@ namespace OpenSim
286 pluginAssembly = null; 293 pluginAssembly = null;
287 return config; 294 return config;
288 } 295 }
289 296
290 private void OnReceivedData(IAsyncResult result) 297 private void OnReceivedData(IAsyncResult result)
291 { 298 {
292 ipeSender = new IPEndPoint(IPAddress.Any, 0); 299 ipeSender = new IPEndPoint(IPAddress.Any, 0);
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;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using libsecondlife; 30using libsecondlife;
31using libsecondlife.Packets; 31using libsecondlife.Packets;
32using Nwc.XmlRpc;
32using System.Net; 33using System.Net;
33using System.Net.Sockets; 34using System.Net.Sockets;
34using System.IO; 35using 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");
diff --git a/OpenSim.RegionServer/world/Avatar.cs b/OpenSim.RegionServer/world/Avatar.cs
index 42a2067..b6b8282 100644
--- a/OpenSim.RegionServer/world/Avatar.cs
+++ b/OpenSim.RegionServer/world/Avatar.cs
@@ -44,7 +44,7 @@ namespace OpenSim.world
44 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); 44 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
45 ControllingClient = TheClient; 45 ControllingClient = TheClient;
46 localid = 8880000 + (this.m_world._localNumber++); 46 localid = 8880000 + (this.m_world._localNumber++);
47 Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain[(int)Pos.X, (int)Pos.Y] + 1.0f); 47 Pos = ControllingClient.startpos;
48 visualParams = new byte[218]; 48 visualParams = new byte[218];
49 for (int i = 0; i < 218; i++) 49 for (int i = 0; i < 218; i++)
50 { 50 {
@@ -131,7 +131,7 @@ namespace OpenSim.world
131 mov.Data.RegionHandle = this.m_regionHandle; 131 mov.Data.RegionHandle = this.m_regionHandle;
132 // TODO - dynamicalise this stuff 132 // TODO - dynamicalise this stuff
133 mov.Data.Timestamp = 1172750370; 133 mov.Data.Timestamp = 1172750370;
134 mov.Data.Position = new LLVector3(100f, 100f, 23f); 134 mov.Data.Position = this.ControllingClient.startpos;
135 mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0); 135 mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0);
136 136
137 ControllingClient.OutPacket(mov); 137 ControllingClient.OutPacket(mov);
diff --git a/OpenSim.RegionServer/world/AvatarUpdate.cs b/OpenSim.RegionServer/world/AvatarUpdate.cs
index 453f419..c2f2456 100644
--- a/OpenSim.RegionServer/world/AvatarUpdate.cs
+++ b/OpenSim.RegionServer/world/AvatarUpdate.cs
@@ -59,7 +59,24 @@ namespace OpenSim.world
59 } 59 }
60 60
61 } 61 }
62 this.positionLastFrame = pos2; 62 this.positionLastFrame = pos2;
63
64 if(this._physActor.Position.X < 0) {
65 ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X,this._physActor.Position.Y,this._physActor.Position.Z));
66 }
67
68 if(this._physActor.Position.Y < 0) {
69 ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X,this._physActor.Position.Y,this._physActor.Position.Z));
70 }
71
72 if(this._physActor.Position.X > 255) {
73 ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X,this._physActor.Position.Y,this._physActor.Position.Z));
74 }
75
76 if(this._physActor.Position.Y > 255) {
77 ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X,this._physActor.Position.Y,this._physActor.Position.Z));
78 }
79
63 } 80 }
64 81
65 public ObjectUpdatePacket CreateUpdatePacket() 82 public ObjectUpdatePacket CreateUpdatePacket()