From 05d9593198f1a688e10ab5be1789b5661ad7d61e Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 13 May 2007 12:25:08 +0000 Subject: [PATCH] Added very basic support for maps (likely to only work in sandbox mode due to the non functioning remote asset server), also currently just uses textures that we already had added to the asset server (this is the first thing that needs fixing) --- OpenSim.RegionServer/OpenSimMain.cs | 2 +- OpenSim.RegionServer/SimClient.cs | 35 +++++++++++++++++-- OpenSim.RegionServer/world/Primitive2.cs | 22 ++++++++++-- OpenSim.RegionServer/world/World.cs | 5 +-- .../world/WorldPacketHandlers.cs | 30 +++++++++++++--- OpenSim.Servers/LoginServer.cs | 28 +++++++-------- OpenSim/Application.cs | 4 +-- 7 files changed, 98 insertions(+), 28 deletions(-) diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs index d522e2bcb2..9fb7c4ed03 100644 --- a/OpenSim.RegionServer/OpenSimMain.cs +++ b/OpenSim.RegionServer/OpenSimMain.cs @@ -225,7 +225,7 @@ namespace OpenSim m_console.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL,"Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString()); m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Initialising world"); - LocalWorld = new World(this._packetServer.ClientThreads, regionData.RegionHandle, regionData.RegionName); + LocalWorld = new World(this._packetServer.ClientThreads, regionData, regionData.RegionHandle, regionData.RegionName); LocalWorld.InventoryCache = InventoryCache; LocalWorld.AssetCache = AssetCache; diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/SimClient.cs index 76bf46e1d2..ab13b02938 100644 --- a/OpenSim.RegionServer/SimClient.cs +++ b/OpenSim.RegionServer/SimClient.cs @@ -144,7 +144,7 @@ namespace OpenSim public void CrossSimBorder(LLVector3 avatarpos) { // VERY VERY BASIC - + LLVector3 newpos = avatarpos; uint neighbourx = this.m_regionData.RegionLocX; uint neighboury = this.m_regionData.RegionLocY; @@ -642,6 +642,13 @@ namespace OpenSim } } break; + case PacketType.MapLayerRequest: + this.RequestMapLayer(); + break; + case PacketType.MapBlockRequest: + MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack; + this.RequestMapBlock( MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); + break; } } @@ -1101,7 +1108,7 @@ namespace OpenSim case 3: // Landmark String content; - content = "Landmark version 2\n"; + content = "Landmark version 2\n"; content += "region_id " + m_regionData.SimUUID + "\n"; String strPos = String.Format("%.2f %.2f %.2f>", this.ClientAvatar.Pos.X, @@ -1116,5 +1123,29 @@ namespace OpenSim m_assetCache.AddAsset(asset); m_inventoryCache.AddNewInventoryItem(this, packet.InventoryBlock.FolderID, asset); } + + public void RequestMapLayer() //should be getting the map layer from the grid server + { + //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area) + MapLayerReplyPacket mapReply = new MapLayerReplyPacket(); + mapReply.AgentData.AgentID = this.AgentID; + mapReply.AgentData.Flags = 0; + mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1]; + mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock(); + mapReply.LayerData[0].Bottom = 800; + mapReply.LayerData[0].Left = 800; + mapReply.LayerData[0].Top = 1200; + mapReply.LayerData[0].Right = 1200; + mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000001"); + this.OutPacket(mapReply); + } + + public void RequestMapBlock( int minX, int minY, int maxX, int maxY) + { + //check if our own map was requested + this.m_world.RequestMapBlock(this, minX, minY, maxX, maxY); + + //now should get other regions maps from gridserver + } } } diff --git a/OpenSim.RegionServer/world/Primitive2.cs b/OpenSim.RegionServer/world/Primitive2.cs index 0df3079353..5e76fd128e 100644 --- a/OpenSim.RegionServer/world/Primitive2.cs +++ b/OpenSim.RegionServer/world/Primitive2.cs @@ -45,7 +45,17 @@ namespace OpenSim.world this._physActor = value; } } - + public override LLVector3 Pos + { + get + { + return base.Pos; + } + set + { + base.Pos = value; + } + } #endregion public Primitive2(Dictionary clientThreads, ulong regionHandle, World world) @@ -106,6 +116,11 @@ namespace OpenSim.world #region Packet handlers + public void UpdatePosition(LLVector3 pos) + { + + } + public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket) { this.primData.PathBegin = addPacket.PathBegin; @@ -230,6 +245,7 @@ namespace OpenSim.world #region Update viewers Methods + //should change these mehtods, so that outgoing packets are sent through the avatar class public void SendFullUpdateToClient(SimClient remoteClient) { LLVector3 lPos; @@ -346,7 +362,7 @@ namespace OpenSim.world objdata.ObjectData[47] = 63; } - protected void UpdatePacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData) + protected void SetPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData) { objectData.OwnerID = this.primData.OwnerID; objectData.PCode = this.primData.PCode; @@ -378,7 +394,7 @@ namespace OpenSim.world ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); this.SetDefaultPacketValues(objupdate); objupdate.UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456; - this.UpdatePacketShapeData(objupdate); + this.SetPacketShapeData(objupdate); byte[] pb = this.Pos.GetBytes(); Array.Copy(pb, 0, objupdate.ObjectData, 0, pb.Length); return objupdate; diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs index 225ce81cc7..445df1d496 100644 --- a/OpenSim.RegionServer/world/World.cs +++ b/OpenSim.RegionServer/world/World.cs @@ -43,7 +43,7 @@ namespace OpenSim.world private InventoryCache _inventoryCache; private AssetCache _assetCache; private Mutex updateLock; - + private RegionInfo m_regInfo; public string m_datastore; /// @@ -52,7 +52,7 @@ namespace OpenSim.world /// Dictionary to contain client threads /// Region Handle for this region /// Region Name for this region - public World(Dictionary clientThreads, ulong regionHandle, string regionName) + public World(Dictionary clientThreads, RegionInfo regInfo, ulong regionHandle, string regionName) { try { @@ -60,6 +60,7 @@ namespace OpenSim.world m_clientThreads = clientThreads; m_regionHandle = regionHandle; m_regionName = regionName; + m_regInfo = regInfo; m_scriptHandlers = new Dictionary(); m_scripts = new Dictionary(); diff --git a/OpenSim.RegionServer/world/WorldPacketHandlers.cs b/OpenSim.RegionServer/world/WorldPacketHandlers.cs index 9e1f9a1924..d479c85b04 100644 --- a/OpenSim.RegionServer/world/WorldPacketHandlers.cs +++ b/OpenSim.RegionServer/world/WorldPacketHandlers.cs @@ -65,28 +65,28 @@ namespace OpenSim.world switch (inchatpack.ChatData.Type) { case 0: - int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X),(int)( client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); + int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); if ((dis < 10) && (dis > -10)) { client.OutPacket(reply); } break; case 1: - dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); + dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); if ((dis < 30) && (dis > -30)) { client.OutPacket(reply); } break; case 2: - dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X),(int)( client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); + dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); if ((dis < 100) && (dis > -100)) { client.OutPacket(reply); } break; } - + } return true; } @@ -203,5 +203,27 @@ namespace OpenSim.world return true; } + public void RequestMapBlock(SimClient simClient, int minX, int minY, int maxX, int maxY) + { + System.Text.Encoding _enc = System.Text.Encoding.ASCII; + if (((m_regInfo.RegionLocX > minX) && (m_regInfo.RegionLocX < maxX)) && ((m_regInfo.RegionLocY > minY) && (m_regInfo.RegionLocY < maxY))) + { + MapBlockReplyPacket mapReply = new MapBlockReplyPacket(); + mapReply.AgentData.AgentID = simClient.AgentID; + mapReply.AgentData.Flags = 0; + mapReply.Data = new MapBlockReplyPacket.DataBlock[1]; + mapReply.Data[0] = new MapBlockReplyPacket.DataBlock(); + mapReply.Data[0].MapImageID = new LLUUID("00000000-0000-0000-9999-000000000002"); + mapReply.Data[0].X = (ushort)m_regInfo.RegionLocX; + mapReply.Data[0].Y = (ushort)m_regInfo.RegionLocY; + mapReply.Data[0].WaterHeight =(byte) m_regInfo.RegionWaterHeight; + mapReply.Data[0].Name = _enc.GetBytes(this.m_regionName); + mapReply.Data[0].RegionFlags = 72458694; + mapReply.Data[0].Access = 13; + mapReply.Data[0].Agents = 1; //should send number of clients connected + simClient.OutPacket(mapReply); + } + } + } } diff --git a/OpenSim.Servers/LoginServer.cs b/OpenSim.Servers/LoginServer.cs index 5c829ae448..44038ff52d 100644 --- a/OpenSim.Servers/LoginServer.cs +++ b/OpenSim.Servers/LoginServer.cs @@ -168,21 +168,21 @@ namespace OpenSim.UserServer XmlRpcResponse response = loginResponse.ToXmlRpcResponse(); Hashtable responseData = (Hashtable)response.Value; - // inventory - // ArrayList InventoryList = (ArrayList)responseData["inventory-skeleton"]; - // Hashtable Inventory1 = (Hashtable)InventoryList[0]; - // Hashtable Inventory2 = (Hashtable)InventoryList[1]; - // LLUUID BaseFolderID = LLUUID.Random(); - // LLUUID InventoryFolderID = LLUUID.Random(); - // Inventory2["name"] = "Textures"; - // Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated(); - // Inventory2["type_default"] = 0; - // Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated(); - - // ArrayList InventoryRoot = (ArrayList)responseData["inventory-root"]; - // Hashtable Inventoryroot = (Hashtable)InventoryRoot[0]; - // Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated(); + //inventory + /* ArrayList InventoryList = (ArrayList)responseData["inventory-skeleton"]; + Hashtable Inventory1 = (Hashtable)InventoryList[0]; + Hashtable Inventory2 = (Hashtable)InventoryList[1]; + LLUUID BaseFolderID = LLUUID.Random(); + LLUUID InventoryFolderID = LLUUID.Random(); + Inventory2["name"] = "Textures"; + Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated(); + Inventory2["type_default"] = 0; + Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated(); + ArrayList InventoryRoot = (ArrayList)responseData["inventory-root"]; + Hashtable Inventoryroot = (Hashtable)InventoryRoot[0]; + Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated(); + */ CustomiseLoginResponse(responseData, first, last); Login _login = new Login(); diff --git a/OpenSim/Application.cs b/OpenSim/Application.cs index 92951b1e96..4b475a161d 100644 --- a/OpenSim/Application.cs +++ b/OpenSim/Application.cs @@ -31,11 +31,11 @@ namespace OpenSim sandBoxMode = true; startLoginServer = true; } - + /* if (args[i] == "-loginserver") { startLoginServer = true; - } + }*/ if (args[i] == "-accounts") { userAccounts = true;