Sim crossing now works (except for broken co-ordinates, resets to 0,0 - to be fixed soon)
Fixed sandbox mode fully Scrapped former XML-RPC expect_user call for sim crossings Sim client thread can upgrade/downgrade between full and child agent dynamically0.1-prestable
parent
990680027f
commit
bbcb20e192
|
@ -11,6 +11,7 @@ namespace OpenSim.Framework.Interfaces
|
|||
public LLUUID AgentID;
|
||||
public LLUUID SessionID;
|
||||
public LLUUID SecureSessionID;
|
||||
public LLVector3 startpos;
|
||||
public string firstname;
|
||||
public string lastname;
|
||||
public uint circuitcode;
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace OpenSim.Framework.Sims
|
|||
|
||||
Hashtable RespData = (Hashtable)GridResp.Value;
|
||||
this.UUID = new LLUUID((string)RespData["UUID"]);
|
||||
this.regionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256));
|
||||
this.regionhandle = Helpers.UIntsToLong(((uint)Convert.ToUInt32(RespData["region_locx"]) * 256), ((uint)Convert.ToUInt32(RespData["region_locy"]) * 256));
|
||||
this.regionname = (string)RespData["regionname"];
|
||||
this.sim_ip = (string)RespData["sim_ip"];
|
||||
this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]);
|
||||
|
@ -57,7 +57,7 @@ namespace OpenSim.Framework.Sims
|
|||
|
||||
Hashtable RespData = (Hashtable)GridResp.Value;
|
||||
this.UUID = new LLUUID((string)RespData["UUID"]);
|
||||
this.regionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256));
|
||||
this.regionhandle = Helpers.UIntsToLong(((uint)Convert.ToUInt32(RespData["region_locx"]) * 256), ((uint)Convert.ToUInt32(RespData["region_locy"]) * 256));
|
||||
this.regionname = (string)RespData["regionname"];
|
||||
this.sim_ip = (string)RespData["sim_ip"];
|
||||
this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]);
|
||||
|
|
|
@ -258,7 +258,10 @@ namespace OpenSim.Framework.User
|
|||
SimParams["firstname"] = theUser.firstname;
|
||||
SimParams["lastname"] = theUser.lastname;
|
||||
SimParams["agent_id"] = theUser.UUID.ToString();
|
||||
SimParams["circuit_code"] = (Int32)circode;
|
||||
SimParams["circuit_code"] = (Int32)circode;
|
||||
SimParams["startpos_x"] = theUser.homepos.X.ToString();
|
||||
SimParams["startpos_y"] = theUser.homepos.Y.ToString();
|
||||
SimParams["startpos_z"] = theUser.homepos.Z.ToString();
|
||||
ArrayList SendParams = new ArrayList();
|
||||
SendParams.Add(SimParams);
|
||||
|
||||
|
|
|
@ -109,26 +109,34 @@ namespace OpenSim.Physics.BasicPhysicsPlugin
|
|||
{*/
|
||||
actor.Position.Z = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X]+1;
|
||||
//}
|
||||
if(actor.Position.X<0)
|
||||
|
||||
|
||||
|
||||
// This code needs sorting out - border crossings etc
|
||||
/* if(actor.Position.X<0)
|
||||
{
|
||||
ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
|
||||
actor.Position.X = 0;
|
||||
actor.Velocity.X = 0;
|
||||
}
|
||||
if(actor.Position.Y < 0)
|
||||
{
|
||||
ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
|
||||
actor.Position.Y = 0;
|
||||
actor.Velocity.Y = 0;
|
||||
}
|
||||
if(actor.Position.X > 255)
|
||||
{
|
||||
ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
|
||||
actor.Position.X = 255;
|
||||
actor.Velocity.X = 0;
|
||||
}
|
||||
if(actor.Position.Y > 255)
|
||||
{
|
||||
ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
|
||||
actor.Position.Y = 255;
|
||||
actor.Velocity.X = 0;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace OpenSim
|
|||
//private Dictionary<uint, SimClient> ClientThreads = new Dictionary<uint, SimClient>();
|
||||
private Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
|
||||
private DateTime startuptime;
|
||||
private RegionInfo regionData;
|
||||
public RegionInfo regionData;
|
||||
|
||||
public Socket Server;
|
||||
private IPEndPoint ServerIncoming;
|
||||
|
@ -206,12 +206,19 @@ namespace OpenSim
|
|||
agent_data.firstname = (string)requestData["firstname"];
|
||||
agent_data.lastname = (string)requestData["lastname"];
|
||||
agent_data.AgentID = new LLUUID((string)requestData["agent_id"]);
|
||||
agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
|
||||
if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
|
||||
{
|
||||
agent_data.child = true;
|
||||
}
|
||||
((RemoteGridBase)gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data);
|
||||
agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
|
||||
if(requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1")) {
|
||||
agent_data.child=true;
|
||||
} else {
|
||||
agent_data.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]),Convert.ToUInt32(requestData["startpos_y"]),Convert.ToUInt32(requestData["startpos_z"]));
|
||||
agent_data.child=false;
|
||||
}
|
||||
|
||||
if(((RemoteGridBase)gridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode)) {
|
||||
((RemoteGridBase)gridServer).agentcircuits[(uint)agent_data.circuitcode]=agent_data;
|
||||
} else {
|
||||
((RemoteGridBase)gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data);
|
||||
}
|
||||
|
||||
return new XmlRpcResponse();
|
||||
});
|
||||
|
@ -286,7 +293,7 @@ namespace OpenSim
|
|||
pluginAssembly = null;
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
private void OnReceivedData(IAsyncResult result)
|
||||
{
|
||||
ipeSender = new IPEndPoint(IPAddress.Any, 0);
|
||||
|
|
|
@ -29,6 +29,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
using Nwc.XmlRpc;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.IO;
|
||||
|
@ -58,8 +59,9 @@ namespace OpenSim
|
|||
public uint CircuitCode;
|
||||
public world.Avatar ClientAvatar;
|
||||
private UseCircuitCodePacket cirpack;
|
||||
private Thread ClientThread;
|
||||
public EndPoint userEP;
|
||||
public Thread ClientThread;
|
||||
public EndPoint userEP;
|
||||
public LLVector3 startpos;
|
||||
private BlockingQueue<QueItem> PacketQueue;
|
||||
private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>();
|
||||
private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>();
|
||||
|
@ -109,6 +111,11 @@ namespace OpenSim
|
|||
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request");
|
||||
cirpack = initialcirpack;
|
||||
userEP = remoteEP;
|
||||
if(m_gridServer.GetName() == "Remote") {
|
||||
this.startpos=((RemoteGridBase)m_gridServer).agentcircuits[initialcirpack.CircuitCode.Code].startpos;
|
||||
} else {
|
||||
this.startpos=new LLVector3(128.0f,128.0f,60f);
|
||||
}
|
||||
PacketQueue = new BlockingQueue<QueItem>();
|
||||
|
||||
this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
|
||||
|
@ -130,6 +137,100 @@ namespace OpenSim
|
|||
this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate);
|
||||
}
|
||||
|
||||
public void CrossSimBorder(LLVector3 avatarpos) { // VERY VERY BASIC
|
||||
LLVector3 newpos = avatarpos;
|
||||
uint neighbourx=((OpenSimMain)m_application).regionData.RegionLocX;
|
||||
uint neighboury=((OpenSimMain)m_application).regionData.RegionLocY;
|
||||
|
||||
if(avatarpos.X<0) {
|
||||
neighbourx-=1;
|
||||
newpos.X=0;
|
||||
}
|
||||
if(avatarpos.X>255) {
|
||||
neighbourx+=1;
|
||||
newpos.X=255;
|
||||
}
|
||||
if(avatarpos.Y<0) {
|
||||
neighboury-=1;
|
||||
newpos.Y=0;
|
||||
}
|
||||
if(avatarpos.Y>255) {
|
||||
neighbourx+=1;
|
||||
newpos.Y=255;
|
||||
}
|
||||
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimClient.cs:CrossSimBorder() - Crossing border to neighbouring sim at [" + neighbourx.ToString() + "," + neighboury.ToString() + "]");
|
||||
|
||||
Hashtable SimParams;
|
||||
ArrayList SendParams;
|
||||
XmlRpcRequest GridReq;
|
||||
XmlRpcResponse GridResp;
|
||||
foreach(Hashtable borderingSim in ((RemoteGridBase)m_gridServer).neighbours) {
|
||||
if(((string)borderingSim["region_locx"]).Equals(neighbourx.ToString()) && ((string)borderingSim["region_locy"]).Equals(neighboury.ToString())) {
|
||||
CrossedRegionPacket NewSimPack = new CrossedRegionPacket();
|
||||
NewSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
|
||||
NewSimPack.AgentData.AgentID=this.AgentID;
|
||||
NewSimPack.AgentData.SessionID=this.SessionID;
|
||||
NewSimPack.Info = new CrossedRegionPacket.InfoBlock();
|
||||
NewSimPack.Info.Position=newpos;
|
||||
NewSimPack.Info.LookAt=new LLVector3(0.99f, 0.042f, 0); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!!
|
||||
NewSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock();
|
||||
NewSimPack.RegionData.RegionHandle=Helpers.UIntsToLong((uint)(Convert.ToInt32(borderingSim["region_locx"]) * 256), (uint)(Convert.ToInt32(borderingSim["region_locy"]) * 256));
|
||||
|
||||
System.Net.IPAddress neighbourIP = System.Net.IPAddress.Parse((string)borderingSim["sim_ip"]);
|
||||
byte[] byteIP = neighbourIP.GetAddressBytes();
|
||||
NewSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
|
||||
NewSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
|
||||
NewSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
|
||||
NewSimPack.RegionData.SimIP += (uint)byteIP[0];
|
||||
NewSimPack.RegionData.SimPort = (ushort)Convert.ToInt32(borderingSim["sim_port"]);
|
||||
NewSimPack.RegionData.SeedCapability = new byte[0];
|
||||
lock(PacketQueue) {
|
||||
ProcessOutPacket(NewSimPack);
|
||||
DowngradeClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpgradeClient() {
|
||||
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimClient.cs:UpgradeClient() - upgrading child to full agent");
|
||||
this.m_child=false;
|
||||
this.m_world.RemoveViewerAgent(this);
|
||||
this.InitNewClient();
|
||||
}
|
||||
|
||||
public void DowngradeClient() {
|
||||
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimClient.cs:UpgradeClient() - changing full agent to child");
|
||||
this.m_child=true;
|
||||
this.m_world.RemoveViewerAgent(this);
|
||||
this.m_world.AddViewerAgent(this);
|
||||
}
|
||||
|
||||
public void KillClient() {
|
||||
KillObjectPacket kill = new KillObjectPacket();
|
||||
kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
|
||||
kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
|
||||
kill.ObjectData[0].ID = this.ClientAvatar.localid;
|
||||
foreach (SimClient client in m_clientThreads.Values)
|
||||
{
|
||||
client.OutPacket(kill);
|
||||
}
|
||||
if (this.m_userServer != null)
|
||||
{
|
||||
this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_inventoryCache.ClientLeaving(this.AgentID, null);
|
||||
}
|
||||
|
||||
m_world.RemoveViewerAgent(this);
|
||||
|
||||
m_clientThreads.Remove(this.CircuitCode);
|
||||
m_application.RemoveClientCircuit(this.CircuitCode);
|
||||
this.ClientThread.Abort();
|
||||
}
|
||||
|
||||
public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
|
||||
{
|
||||
bool result = false;
|
||||
|
@ -230,10 +331,9 @@ namespace OpenSim
|
|||
switch (Pack.Type)
|
||||
{
|
||||
case PacketType.CompleteAgentMovement:
|
||||
if(!m_child) {
|
||||
ClientAvatar.CompleteMovement(m_world);
|
||||
ClientAvatar.SendInitialPosition();
|
||||
}
|
||||
if(this.m_child) this.UpgradeClient();
|
||||
ClientAvatar.CompleteMovement(m_world);
|
||||
ClientAvatar.SendInitialPosition();
|
||||
break;
|
||||
case PacketType.RegionHandshakeReply:
|
||||
m_world.SendLayerData(this);
|
||||
|
@ -797,7 +897,7 @@ namespace OpenSim
|
|||
}
|
||||
}
|
||||
#region Packet handlers
|
||||
|
||||
|
||||
protected virtual bool Logout(SimClient simClient, Packet packet)
|
||||
{
|
||||
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request");
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace OpenSim.world
|
|||
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
|
||||
ControllingClient = TheClient;
|
||||
localid = 8880000 + (this.m_world._localNumber++);
|
||||
Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain[(int)Pos.X, (int)Pos.Y] + 1.0f);
|
||||
Pos = ControllingClient.startpos;
|
||||
visualParams = new byte[218];
|
||||
for (int i = 0; i < 218; i++)
|
||||
{
|
||||
|
@ -131,7 +131,7 @@ namespace OpenSim.world
|
|||
mov.Data.RegionHandle = this.m_regionHandle;
|
||||
// TODO - dynamicalise this stuff
|
||||
mov.Data.Timestamp = 1172750370;
|
||||
mov.Data.Position = new LLVector3(100f, 100f, 23f);
|
||||
mov.Data.Position = this.ControllingClient.startpos;
|
||||
mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0);
|
||||
|
||||
ControllingClient.OutPacket(mov);
|
||||
|
|
|
@ -59,7 +59,24 @@ namespace OpenSim.world
|
|||
}
|
||||
|
||||
}
|
||||
this.positionLastFrame = pos2;
|
||||
this.positionLastFrame = pos2;
|
||||
|
||||
if(this._physActor.Position.X < 0) {
|
||||
ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X,this._physActor.Position.Y,this._physActor.Position.Z));
|
||||
}
|
||||
|
||||
if(this._physActor.Position.Y < 0) {
|
||||
ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X,this._physActor.Position.Y,this._physActor.Position.Z));
|
||||
}
|
||||
|
||||
if(this._physActor.Position.X > 255) {
|
||||
ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X,this._physActor.Position.Y,this._physActor.Position.Z));
|
||||
}
|
||||
|
||||
if(this._physActor.Position.Y > 255) {
|
||||
ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X,this._physActor.Position.Y,this._physActor.Position.Z));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ObjectUpdatePacket CreateUpdatePacket()
|
||||
|
|
Loading…
Reference in New Issue