From b3844c1f7348b4296b5ab1df258935d7f971e412 Mon Sep 17 00:00:00 2001 From: gareth Date: Wed, 7 Mar 2007 18:48:38 +0000 Subject: Deleted old trunk code --- src/Config.cs | 174 -------------- src/Main.cs | 159 ------------- src/OpenSimClient.cs | 510 ----------------------------------------- src/Second-server.csproj | 65 ------ src/Second-server.sln | 26 --- src/ServerConsole.cs | 195 ---------------- src/Util.cs | 75 ------ src/VersionInfo.cs | 37 --- src/VersionInfo.cs.template | 37 --- src/types/Mesh.cs | 28 --- src/types/Triangle.cs | 28 --- src/world/Avatar.cs | 256 --------------------- src/world/Entity.cs | 65 ------ src/world/HeightmapGenHills.cs | 122 ---------- src/world/PhysicsEngine.cs | 32 --- src/world/Primitive.cs | 33 --- src/world/ScriptEngine.cs | 18 -- src/world/SurfacePatch.cs | 22 -- src/world/World.cs | 112 --------- src/world/scripting/IScript.cs | 16 -- 20 files changed, 2010 deletions(-) delete mode 100644 src/Config.cs delete mode 100644 src/Main.cs delete mode 100644 src/OpenSimClient.cs delete mode 100644 src/Second-server.csproj delete mode 100644 src/Second-server.sln delete mode 100644 src/ServerConsole.cs delete mode 100644 src/Util.cs delete mode 100644 src/VersionInfo.cs delete mode 100644 src/VersionInfo.cs.template delete mode 100644 src/types/Mesh.cs delete mode 100644 src/types/Triangle.cs delete mode 100644 src/world/Avatar.cs delete mode 100644 src/world/Entity.cs delete mode 100644 src/world/HeightmapGenHills.cs delete mode 100644 src/world/PhysicsEngine.cs delete mode 100644 src/world/Primitive.cs delete mode 100644 src/world/ScriptEngine.cs delete mode 100644 src/world/SurfacePatch.cs delete mode 100644 src/world/World.cs delete mode 100644 src/world/scripting/IScript.cs (limited to 'src') diff --git a/src/Config.cs b/src/Config.cs deleted file mode 100644 index 9bb9296..0000000 --- a/src/Config.cs +++ /dev/null @@ -1,174 +0,0 @@ -/* -Copyright (c) OpenSim project, http://osgrid.org/ - -* Copyright (c) , -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Collections.Generic; -using System.IO; -using Db4objects.Db4o; -using libsecondlife; -using OpenSim.world; - -namespace OpenSim -{ - /// - /// This class handles connection to the underlying database used for configuration of the region. - /// Region content is also stored by this class. The main entry point is InitConfig() which attempts to locate - /// opensim.yap in the current working directory. If opensim.yap can not be found, default settings are loaded from - /// what is hardcoded here and then saved into opensim.yap for future startups. - /// - public class SimConfig - { - public string RegionName; - - public uint RegionLocX; - public uint RegionLocY; - public ulong RegionHandle; - - public int IPListenPort; - public string IPListenAddr; - - public bool sandbox = true; - public string AssetURL = String.Empty; - public string AssetSendKey = String.Empty; - - public string GridURL = String.Empty; - public string GridSendKey = String.Empty; - - private IObjectContainer db; - - public void LoadDefaults() - { - string tempstring; - OpenSim_Main.localcons.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); - - this.RegionName = OpenSim_Main.localcons.CmdPrompt("Name [OpenSim test]: ", "OpenSim test"); - this.RegionLocX = (uint)Convert.ToInt32(OpenSim_Main.localcons.CmdPrompt("Grid Location X [997]: ", "997")); - this.RegionLocY = (uint)Convert.ToInt32(OpenSim_Main.localcons.CmdPrompt("Grid Location Y [996]: ", "996")); - this.IPListenPort = Convert.ToInt32(OpenSim_Main.localcons.CmdPrompt("UDP port for client connections [9000]: ", "9000")); - this.IPListenAddr = OpenSim_Main.localcons.CmdPrompt("IP Address to listen on for client connections [127.0.0.1]: ", "127.0.0.1"); - - tempstring = OpenSim_Main.localcons.CmdPrompt("Run in sandbox or grid mode? [sandbox]: ", "sandbox", "sandbox", "grid"); - this.sandbox = tempstring.Equals("sandbox"); - - if (!this.sandbox) - { - this.AssetURL = OpenSim_Main.localcons.CmdPrompt("Asset server URL: "); - this.AssetSendKey = OpenSim_Main.localcons.CmdPrompt("Asset server key: "); - this.GridURL = OpenSim_Main.localcons.CmdPrompt("Grid server URL: "); - this.GridSendKey = OpenSim_Main.localcons.CmdPrompt("Grid server key: "); - } - this.RegionHandle = Helpers.UIntsToLong((RegionLocX * 256), (RegionLocY * 256)); - } - - public void InitConfig() - { - try - { - db = Db4oFactory.OpenFile("opensim.yap"); - IObjectSet result = db.Get(typeof(SimConfig)); - if (result.Count == 1) - { - OpenSim_Main.localcons.WriteLine("Config.cs:InitConfig() - Found a SimConfig object in the local database, loading"); - foreach (SimConfig cfg in result) - { - this.sandbox = cfg.sandbox; - this.RegionName = cfg.RegionName; - this.RegionLocX = cfg.RegionLocX; - this.RegionLocY = cfg.RegionLocY; - this.RegionHandle = Helpers.UIntsToLong((RegionLocX * 256), (RegionLocY * 256)); - this.IPListenPort = cfg.IPListenPort; - this.IPListenAddr = cfg.IPListenAddr; - this.AssetURL = cfg.AssetURL; - this.AssetSendKey = cfg.AssetSendKey; - this.GridURL = cfg.GridURL; - this.GridSendKey = cfg.GridSendKey; - } - } - else - { - OpenSim_Main.localcons.WriteLine("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults"); - LoadDefaults(); - OpenSim_Main.localcons.WriteLine("Writing out default settings to local database"); - db.Set(this); - } - } - catch (Exception e) - { - db.Close(); - OpenSim_Main.localcons.WriteLine("Config.cs:InitConfig() - Exception occured"); - OpenSim_Main.localcons.WriteLine(e.ToString()); - } - OpenSim_Main.localcons.WriteLine("Sim settings loaded:"); - OpenSim_Main.localcons.WriteLine("Name: " + this.RegionName); - OpenSim_Main.localcons.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); - OpenSim_Main.localcons.WriteLine("Region Handle: " + this.RegionHandle.ToString()); - OpenSim_Main.localcons.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort); - OpenSim_Main.localcons.WriteLine("Sandbox Mode? " + this.sandbox.ToString()); - OpenSim_Main.localcons.WriteLine("Asset URL: " + this.AssetURL); - OpenSim_Main.localcons.WriteLine("Asset key: " + this.AssetSendKey); - OpenSim_Main.localcons.WriteLine("Grid URL: " + this.GridURL); - OpenSim_Main.localcons.WriteLine("Grid key: " + this.GridSendKey); - } - - public World LoadWorld() - { - OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - Loading world...."); - World blank = new World(); - OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - Looking for a heightmap in local DB"); - IObjectSet world_result = db.Get(new float[65536]); - if (world_result.Count > 0) - { - OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - Found a heightmap in local database, loading"); - blank.LandMap = (float[])world_result.Next(); - } - else - { - OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - No heightmap found, generating new one"); - HeightmapGenHills hills = new HeightmapGenHills(); - blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); - - OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - Saving heightmap to local database"); - db.Set(blank.LandMap); - db.Commit(); - } - return blank; - } - - public void LoadFromGrid() - { - OpenSim_Main.localcons.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!"); - // TODO: Make this crap work - } - - public void Shutdown() - { - db.Close(); - } - } -} diff --git a/src/Main.cs b/src/Main.cs deleted file mode 100644 index f3fa609..0000000 --- a/src/Main.cs +++ /dev/null @@ -1,159 +0,0 @@ -/* -Copyright (c) OpenSim project, http://osgrid.org/ - - -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Text; -using System.IO; -using System.Threading; -using System.Net; -using System.Net.Sockets; -using System.Collections; -using System.Collections.Generic; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.world; - -namespace OpenSim -{ - /// - /// Description of MainForm. - /// - public class OpenSim_Main - { - public static DateTime startuptime; - public static OpenSim_Main sim; - public static SimConfig cfg; - public static World local_world; - public static ServerConsole localcons; - private static Thread MainListener; - public static Socket Server; - private static IPEndPoint ServerIncoming; - private static byte[] RecvBuffer = new byte[4096]; - private byte[] ZeroBuffer = new byte[8192]; - private static IPEndPoint ipeSender; - private static EndPoint epSender; - private static AsyncCallback ReceivedData; - public Dictionary ClientThreads = new Dictionary(); - - [STAThread] - public static void Main( string[] args ) - { - Console.WriteLine("OpenSim " + VersionInfo.Version + "\n"); - Console.WriteLine("Starting...\n"); - sim = new OpenSim_Main(); - sim.Startup(); - while(true) { - localcons.MainConsolePrompt(); - } - } - - private OpenSim_Main() { - } - - public static void Shutdown() { - localcons.WriteLine("Main.cs:Shutdown() - Closing all threads"); - localcons.WriteLine("Main.cs:Shutdown() - Killing listener thread"); - MainListener.Abort(); - localcons.WriteLine("Main.cs:Shutdown() - Killing clients"); - // IMPLEMENT THIS - localcons.WriteLine("Main.cs:Shutdown() - Closing console and terminating"); - localcons.Close(); - Environment.Exit(0); - } - - private void Startup() { - startuptime=DateTime.Now; - localcons=new ServerConsole(ServerConsole.ConsoleType.Local,"",0); - // We check our local database first, then the grid for config options - localcons.WriteLine("Main.cs:Startup() - Loading configuration"); - cfg = new SimConfig(); - cfg.InitConfig(); - localcons.WriteLine("Main.cs:Startup() - Contacting gridserver"); - cfg.LoadFromGrid(); - - localcons.WriteLine("Main.cs:Startup() - We are " + cfg.RegionName + " at " + cfg.RegionLocX.ToString() + "," + cfg.RegionLocY.ToString()); - localcons.WriteLine("Initialising world"); - local_world = cfg.LoadWorld(); - - localcons.WriteLine("Main.cs:Startup() - Starting up main world loop"); - local_world.InitLoop(); - - localcons.WriteLine("Main.cs:Startup() - Starting up messaging system"); - MainListener = new Thread(new ThreadStart(MainServerListener)); - MainListener.Start(); - - Thread.Sleep(500); // give other threads a chance to catch up - string[] noparams = new string[1]; - noparams[0]=""; - localcons.WriteLine("\nOpenSim ready\nType help for list of commands"); - } - - private void OnReceivedData(IAsyncResult result) { - ipeSender = new IPEndPoint(IPAddress.Any, 0); - epSender = (EndPoint)ipeSender; - Packet packet = null; - int numBytes = Server.EndReceiveFrom(result, ref epSender); - int packetEnd = numBytes - 1; - packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); - - // This is either a new client or a packet to send to an old one - if(ClientThreads.ContainsKey(epSender)) { - ClientThreads[epSender].InPacket(packet); - } else if( packet.Type == PacketType.UseCircuitCode ) { // new client - OpenSimClient newuser = new OpenSimClient(epSender,(UseCircuitCodePacket)packet); - ClientThreads.Add(epSender, newuser); - } else { // invalid client - Console.Error.WriteLine("Main.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString()); - } - Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); - } - - private void MainServerListener() { - localcons.WriteLine("Main.cs:MainServerListener() - New thread started"); - localcons.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + cfg.IPListenAddr + ":" + cfg.IPListenPort); - - ServerIncoming = new IPEndPoint(IPAddress.Any, cfg.IPListenPort); - Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - Server.Bind(ServerIncoming); - - localcons.WriteLine("Main.cs:MainServerListener() - UDP socket bound, getting ready to listen"); - - ipeSender = new IPEndPoint(IPAddress.Any, 0); - epSender = (EndPoint) ipeSender; - ReceivedData = new AsyncCallback(this.OnReceivedData); - Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); - - localcons.WriteLine("Main.cs:MainServerListener() - Listening..."); - while(true) { - Thread.Sleep(100); - local_world.DoStuff(); - } - } - } -} diff --git a/src/OpenSimClient.cs b/src/OpenSimClient.cs deleted file mode 100644 index 497df00..0000000 --- a/src/OpenSimClient.cs +++ /dev/null @@ -1,510 +0,0 @@ -/* -Copyright (c) OpenSim project, http://osgrid.org/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Collections; -using System.Collections.Generic; -using libsecondlife; -using libsecondlife.Packets; -using System.Net; -using System.Net.Sockets; -using System.IO; -using System.Threading; -using System.Timers; - -namespace OpenSim -{ - /// - /// Handles new client connections - /// Constructor takes a single Packet and authenticates everything - /// - public class OpenSimClient - { - - public LLUUID AgentID; - public LLUUID SessionID; - public uint CircuitCode; - public world.Avatar ClientAvatar; - private UseCircuitCodePacket cirpack; - private Thread ClientThread; - public EndPoint userEP; - private BlockingQueue PacketQueue; - private BlockingQueue AssetRequests; - private Dictionary PendingAcks = new Dictionary(); - private Dictionary NeedAck = new Dictionary(); - private System.Timers.Timer AckTimer; - private uint Sequence = 0; - private object SequenceLock = new object(); - private const int MAX_APPENDED_ACKS = 10; - private const int RESEND_TIMEOUT = 4000; - private const int MAX_SEQUENCE = 0xFFFFFF; - //private Queue Inbox; - - public void ack_pack(Packet Pack) - { - //libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket(); - //ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; - //ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); - //ack_it.Packets[0].ID = Pack.Header.ID; - //ack_it.Header.Reliable = false; - - //OutPacket(ack_it); - - if (Pack.Header.Reliable) - { - lock (PendingAcks) - { - uint sequence = (uint)Pack.Header.Sequence; - if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; } - } - } - } - - public void AssetLoader() - { - if (OpenSim_Main.cfg.sandbox == false) - { - WebResponse AssetResponse; - byte[] idata; - - OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AssetLoader() - Starting new thread"); - TransferRequestPacket reqPacket = AssetRequests.Dequeue(); - OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AssetLoader() - Got a request, processing it"); - LLUUID AssetID = new LLUUID(reqPacket.TransferInfo.Params, 0); - - try - { - WebRequest AssetLoad = WebRequest.Create(OpenSim_Main.cfg.AssetURL + "getasset/" + OpenSim_Main.cfg.AssetSendKey + "/" + AssetID + "/data"); - AssetResponse = AssetLoad.GetResponse(); - idata = new byte[(int)AssetResponse.ContentLength]; - BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream()); - idata = br.ReadBytes((int)AssetResponse.ContentLength); - br.Close(); - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - return; - } - - TransferInfoPacket Transfer = new TransferInfoPacket(); - Transfer.TransferInfo.ChannelType = 2; - Transfer.TransferInfo.Status = 0; - Transfer.TransferInfo.TargetType = 0; - Transfer.TransferInfo.Params = reqPacket.TransferInfo.Params; - Transfer.TransferInfo.Size = (int)AssetResponse.ContentLength; - Transfer.TransferInfo.TransferID = reqPacket.TransferInfo.TransferID; - - OutPacket(Transfer); - - TransferPacketPacket TransferPacket = new TransferPacketPacket(); - TransferPacket.TransferData.Packet = 0; - TransferPacket.TransferData.ChannelType = 2; - TransferPacket.TransferData.TransferID = reqPacket.TransferInfo.TransferID; - - if (AssetResponse.ContentLength > 1000) - { - byte[] chunk = new byte[1000]; - Array.Copy(idata, chunk, 1000); - TransferPacket.TransferData.Data = chunk; - TransferPacket.TransferData.Status = 0; - OutPacket(TransferPacket); - - TransferPacket = new TransferPacketPacket(); - TransferPacket.TransferData.Packet = 1; - TransferPacket.TransferData.ChannelType = 2; - TransferPacket.TransferData.TransferID = reqPacket.TransferInfo.TransferID; - byte[] chunk1 = new byte[(idata.Length - 1000)]; - Array.Copy(idata, 1000, chunk1, 0, chunk1.Length); - TransferPacket.TransferData.Data = chunk1; - TransferPacket.TransferData.Status = 1; - OutPacket(TransferPacket); - } - else - { - TransferPacket.TransferData.Status = 1; - TransferPacket.TransferData.Data = idata; - OutPacket(TransferPacket); - } - AssetResponse.Close(); - } - } - - public void Logout() - { - // TODO - kill any AssetLoaders - ClientThread.Abort(); - } - - public void ProcessInPacket(Packet Pack) - { - ack_pack(Pack); - switch (Pack.Type) - { - case PacketType.CompleteAgentMovement: - ClientAvatar.CompleteMovement(OpenSim_Main.local_world); - ClientAvatar.SendInitialPosition(); - break; - case PacketType.RegionHandshakeReply: - OpenSim_Main.local_world.SendLayerData(this); - break; - case PacketType.AgentWearablesRequest: - ClientAvatar.SendInitialAppearance(); - break; - case PacketType.TransferRequest: - OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); - // We put transfer requests into a big queue and then spawn a thread for each new one - TransferRequestPacket transfer = (TransferRequestPacket)Pack; - AssetRequests.Enqueue(transfer); - Thread AssetLoaderThread = new Thread(new ThreadStart(AssetLoader)); - AssetLoaderThread.Start(); - break; - case PacketType.LogoutRequest: - OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request"); - lock (OpenSim_Main.local_world.Entities) - { - OpenSim_Main.local_world.Entities.Remove(this.AgentID); - } - - if (OpenSim_Main.cfg.sandbox == false) - { - WebRequest DeleteSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + this.AgentID.ToString() + this.CircuitCode.ToString() + "/delete"); - WebResponse GridResponse = DeleteSession.GetResponse(); - StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); - String grTest = sr.ReadLine(); - sr.Close(); - GridResponse.Close(); - OpenSim_Main.localcons.WriteLine("DEBUG: " + grTest); - } - this.ClientThread.Abort(); - break; - case PacketType.AgentUpdate: - ClientAvatar.HandleAgentUpdate((AgentUpdatePacket)Pack); - break; - case PacketType.ChatFromViewer: - ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; - if (Helpers.FieldToString(inchatpack.ChatData.Message) == "") break; - - System.Text.Encoding _enc = System.Text.Encoding.ASCII; - libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); - reply.ChatData.Audible = 1; - reply.ChatData.Message = inchatpack.ChatData.Message; - reply.ChatData.ChatType = 1; - reply.ChatData.SourceType = 1; - reply.ChatData.Position = this.ClientAvatar.position; - reply.ChatData.FromName = _enc.GetBytes(this.ClientAvatar.firstname + " " + this.ClientAvatar.lastname + "\0"); - reply.ChatData.OwnerID = this.AgentID; - reply.ChatData.SourceID = this.AgentID; - - - - foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) - { - client.OutPacket(reply); - } - break; - } - } - - private void ResendUnacked() - { - int now = Environment.TickCount; - - lock (NeedAck) - { - foreach (Packet packet in NeedAck.Values) - { - if (now - packet.TickCount > RESEND_TIMEOUT) - { - - packet.Header.Resent = true; - OutPacket(packet); - } - } - } - } - - private void SendAcks() - { - lock (PendingAcks) - { - if (PendingAcks.Count > 0) - { - if (PendingAcks.Count > 250) - { - return; - } - - - - int i = 0; - PacketAckPacket acks = new PacketAckPacket(); - acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; - - foreach (uint ack in PendingAcks.Values) - { - acks.Packets[i] = new PacketAckPacket.PacketsBlock(); - acks.Packets[i].ID = ack; - i++; - } - - acks.Header.Reliable = false; - OutPacket(acks); - - PendingAcks.Clear(); - } - } - } - - private void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) - { - SendAcks(); - ResendUnacked(); - } - - public void ProcessOutPacket(Packet Pack) - { - - // Keep track of when this packet was sent out - Pack.TickCount = Environment.TickCount; - - if (!Pack.Header.Resent) - { - // Set the sequence number - lock (SequenceLock) - { - if (Sequence >= MAX_SEQUENCE) - Sequence = 1; - else - Sequence++; - Pack.Header.Sequence = Sequence; - } - - if (Pack.Header.Reliable) //DIRTY HACK - { - lock (NeedAck) - { - if (!NeedAck.ContainsKey(Pack.Header.Sequence)) - { - NeedAck.Add(Pack.Header.Sequence, Pack); - } - else - { - // Client.Log("Attempted to add a duplicate sequence number (" + - // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + - // packet.Type.ToString(), Helpers.LogLevel.Warning); - } - } - - // Don't append ACKs to resent packets, in case that's what was causing the - // delivery to fail - if (!Pack.Header.Resent) - { - // Append any ACKs that need to be sent out to this packet - lock (PendingAcks) - { - if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS && - Pack.Type != PacketType.PacketAck && - Pack.Type != PacketType.LogoutRequest) - { - Pack.Header.AckList = new uint[PendingAcks.Count]; - int i = 0; - - foreach (uint ack in PendingAcks.Values) - { - Pack.Header.AckList[i] = ack; - i++; - } - - PendingAcks.Clear(); - Pack.Header.AppendedAcks = true; - } - } - } - } - } - - - byte[] ZeroOutBuffer = new byte[4096]; - byte[] sendbuffer; - sendbuffer = Pack.ToBytes(); - - try - { - if (Pack.Header.Zerocoded) - { - int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); - OpenSim_Main.Server.SendTo(ZeroOutBuffer, packetsize, SocketFlags.None, userEP); - } - else - { - OpenSim_Main.Server.SendTo(sendbuffer, sendbuffer.Length, SocketFlags.None, userEP); - } - } - catch (Exception) - { - OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); - ClientThread.Abort(); - } - - } - - public void InPacket(Packet NewPack) - { - // Handle appended ACKs - if (NewPack.Header.AppendedAcks) - { - lock (NeedAck) - { - foreach (uint ack in NewPack.Header.AckList) - { - OpenSim_Main.localcons.WriteLine("Got appended ack: " + ack); - NeedAck.Remove(ack); - } - } - } - - // Handle PacketAck packets - if (NewPack.Type == PacketType.PacketAck) - { - PacketAckPacket ackPacket = (PacketAckPacket)NewPack; - - lock (NeedAck) - { - foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) - { - NeedAck.Remove(block.ID); - } - } - } - else if ((NewPack.Type == PacketType.StartPingCheck)) - { - //reply to pingcheck - libsecondlife.Packets.StartPingCheckPacket startPing = (libsecondlife.Packets.StartPingCheckPacket)NewPack; - libsecondlife.Packets.CompletePingCheckPacket endPing = new CompletePingCheckPacket(); - endPing.PingID.PingID = startPing.PingID.PingID; - OutPacket(endPing); - } - else - { - QueItem item = new QueItem(); - item.Packet = NewPack; - item.Incoming = true; - this.PacketQueue.Enqueue(item); - } - - } - - public void OutPacket(Packet NewPack) - { - QueItem item = new QueItem(); - item.Packet = NewPack; - item.Incoming = false; - this.PacketQueue.Enqueue(item); - } - - public OpenSimClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack) - { - OpenSim_Main.localcons.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request"); - cirpack = initialcirpack; - userEP = remoteEP; - PacketQueue = new BlockingQueue(); - AssetRequests = new BlockingQueue(); - AckTimer = new System.Timers.Timer(500); - AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); - AckTimer.Start(); - - ClientThread = new Thread(new ThreadStart(AuthUser)); - ClientThread.IsBackground = true; - ClientThread.Start(); - } - - private void ClientLoop() - { - OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:ClientLoop() - Entered loop"); - while (true) - { - QueItem nextPacket = PacketQueue.Dequeue(); - if (nextPacket.Incoming) - { - //is a incoming packet - ProcessInPacket(nextPacket.Packet); - } - else - { - //is a out going packet - ProcessOutPacket(nextPacket.Packet); - } - } - } - - private void InitNewClient() - { - OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); - OpenSim_Main.local_world.AddViewerAgent(this); - world.Entity tempent = OpenSim_Main.local_world.Entities[this.AgentID]; - this.ClientAvatar = (world.Avatar)tempent; - } - - private void AuthUser() - { - if (OpenSim_Main.cfg.sandbox == false) - { - OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AuthUser() - Authenticating new user request with grid"); - WebRequest CheckSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + cirpack.CircuitCode.ID.ToString() + "/" + cirpack.CircuitCode.Code.ToString() + "/exists"); - OpenSim_Main.localcons.WriteLine(OpenSim_Main.cfg.GridURL); - WebResponse GridResponse = CheckSession.GetResponse(); - StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); - String grTest = sr.ReadLine(); - sr.Close(); - GridResponse.Close(); - if (String.IsNullOrEmpty(grTest) || grTest.Equals("1")) - { // YAY! Valid login - OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString()); - this.AgentID = cirpack.CircuitCode.ID; - this.SessionID = cirpack.CircuitCode.SessionID; - this.CircuitCode = cirpack.CircuitCode.Code; - InitNewClient(); - ClientLoop(); - } - else - { // Invalid - OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString()); - ClientThread.Abort(); - } - } - else - { - this.AgentID = cirpack.CircuitCode.ID; - this.SessionID = cirpack.CircuitCode.SessionID; - this.CircuitCode = cirpack.CircuitCode.Code; - InitNewClient(); - ClientLoop(); - } - } - } - -} diff --git a/src/Second-server.csproj b/src/Second-server.csproj deleted file mode 100644 index 8d55e06..0000000 --- a/src/Second-server.csproj +++ /dev/null @@ -1,65 +0,0 @@ - - - Exe - OpenSim - OpenSim - Debug - AnyCPU - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E} - OpenSim.OpenSim_Main - - - ..\bin\ - False - DEBUG;TRACE - True - Full - True - - - ..\bin\ - True - TRACE - False - None - False - - - - False - ..\bin\Axiom.MathLib.dll - - - - False - ..\bin\libsecondlife.dll - - - False - ..\bin\log4net.dll - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Second-server.sln b/src/Second-server.sln deleted file mode 100644 index 86fc54c..0000000 --- a/src/Second-server.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Second-server", "Second-server.csproj", "{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|.NET 1.1 = Debug|.NET 1.1 - Debug|Any CPU = Debug|Any CPU - Release|.NET 1.1 = Release|.NET 1.1 - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|.NET 1.1.ActiveCfg = Debug|Any CPU - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|.NET 1.1.Build.0 = Debug|Any CPU - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|.NET 1.1.ActiveCfg = Release|Any CPU - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/ServerConsole.cs b/src/ServerConsole.cs deleted file mode 100644 index 21a465d..0000000 --- a/src/ServerConsole.cs +++ /dev/null @@ -1,195 +0,0 @@ -/* -Copyright (c) OpenSim project, http://osgrid.org/ - -* Copyright (c) , -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Threading; -using System.IO; -using System.Net; -using libsecondlife; -using libsecondlife.Packets; - -namespace OpenSim -{ - public class ServerConsole { - private ConsoleType ConsType; - StreamWriter Log; - - public enum ConsoleType { - Local, // Use stdio - TCP, // Use TCP/telnet - SimChat // Use in-world chat (for gods) - } - - - // STUPID HACK ALERT!!!! STUPID HACK ALERT!!!!! - // constype - the type of console to use (see enum ConsoleType) - // sparam - depending on the console type: - // TCP - the IP to bind to (127.0.0.1 if blank) - // Local - param ignored - // SimChat - the AgentID of this sim's admin - // and for the iparam: - // TCP - the port to bind to - // Local - param ignored - // SimChat - the chat channel to accept commands from - public ServerConsole(ConsoleType constype, string sparam, int iparam) { - ConsType = constype; - switch(constype) { - case ConsoleType.Local: - Console.WriteLine("ServerConsole.cs - creating new local console"); - Console.WriteLine("Logs will be saved to current directory in opensim-console.log"); - Log=File.AppendText("opensim-console.log"); - Log.WriteLine("========================================================================"); - Log.WriteLine("OpenSim " + VersionInfo.Version + " Started at " + DateTime.Now.ToString()); - break; - case ConsoleType.TCP: - break; - case ConsoleType.SimChat: - break; - - default: - Console.WriteLine("ServerConsole.cs - what are you smoking? that isn't a valid console type!"); - break; - } - } - - public void Close() { - Log.WriteLine("OpenSim shutdown at " + DateTime.Now.ToString()); - Log.Close(); - } - - // You know what ReadLine() and WriteLine() do, right? And Read() and Write()? Right, you do actually know C#, right? Are you actually a programmer? Do you know english? Do you find my sense of humour in comments irritating? Good, glad you're still here - public void WriteLine(string Line) { - Log.WriteLine(Line); - Console.WriteLine(Line); - return; - } - - public string ReadLine() { - string TempStr=Console.ReadLine(); - Log.WriteLine(TempStr); - return TempStr; - } - - public int Read() { - int TempInt= Console.Read(); - Log.Write((char)TempInt); - return TempInt; - } - - public void Write(string Line) { - Console.Write(Line); - Log.Write(Line); - return; - } - - // Displays a command prompt and waits for the user to enter a string, then returns that string - public string CmdPrompt(string prompt) { - this.Write(prompt); - return this.ReadLine(); - } - - // Displays a command prompt and returns a default value if the user simply presses enter - public string CmdPrompt(string prompt, string defaultresponse) { - string temp=CmdPrompt(prompt); - if(temp=="") { - return defaultresponse; - } else { - return temp; - } - } - - // Displays a command prompt and returns a default value, user may only enter 1 of 2 options - public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) { - bool itisdone=false; - string temp=CmdPrompt(prompt,defaultresponse); - while(itisdone==false) { - if((temp==OptionA) || (temp==OptionB)) { - itisdone=true; - } else { - this.WriteLine("Valid options are " + OptionA + " or " + OptionB); - temp=CmdPrompt(prompt,defaultresponse); - } - } - return temp; - } - - // Runs a command with a number of parameters - public Object RunCmd(string Cmd, string[] cmdparams) { - switch(Cmd) { - case "help": - this.WriteLine("show users - show info about connected users"); - this.WriteLine("shutdown - disconnect all clients and shutdown"); - break; - - case "show": - ShowCommands(cmdparams[0]); - break; - - case "shutdown": - OpenSim_Main.Shutdown(); - break; - } - return null; - } - - // Shows data about something - public void ShowCommands(string ShowWhat) { - switch(ShowWhat) { - case "uptime": - this.WriteLine("OpenSim has been running since " + OpenSim_Main.startuptime.ToString()); - this.WriteLine("That is " + (DateTime.Now-OpenSim_Main.startuptime).ToString()); - break; - case "users": - OpenSim.world.Avatar TempAv; - this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}","Firstname", "Lastname","Agent ID", "Session ID", "Circuit", "IP")); - foreach (libsecondlife.LLUUID UUID in OpenSim_Main.local_world.Entities.Keys) { - TempAv=(OpenSim.world.Avatar)OpenSim_Main.local_world.Entities[UUID]; - this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}",TempAv.firstname, TempAv.lastname,UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString())); - } - break; - } - } - - // Displays a prompt to the user and then runs the command they entered - public void MainConsolePrompt() { - string[] tempstrarray; - string tempstr = this.CmdPrompt("OpenSim-" + OpenSim_Main.cfg.RegionHandle.ToString() + " # "); - tempstrarray = tempstr.Split(' '); - string cmd=tempstrarray[0]; - Array.Reverse(tempstrarray); - Array.Resize(ref tempstrarray,tempstrarray.Length-1); - Array.Reverse(tempstrarray); - string[] cmdparams=(string[])tempstrarray; - RunCmd(cmd,cmdparams); - } - } - -} diff --git a/src/Util.cs b/src/Util.cs deleted file mode 100644 index 3b89b25..0000000 --- a/src/Util.cs +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright (c) OpenSim project, http://osgrid.org/ - -* Copyright (c) , -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Collections.Generic; -using System.Threading; -using libsecondlife; -using libsecondlife.Packets; - -namespace OpenSim -{ - /// - /// - public class QueItem { - public QueItem() - { - } - - public Packet Packet; - public bool Incoming; - } - - - public class BlockingQueue< T > { - private Queue< T > _queue = new Queue< T >(); - private object _queueSync = new object(); - - public void Enqueue(T value) - { - lock(_queueSync) - { - _queue.Enqueue(value); - Monitor.Pulse(_queueSync); - } - } - - public T Dequeue() - { - lock(_queueSync) - { - if( _queue.Count < 1) - Monitor.Wait(_queueSync); - - return _queue.Dequeue(); - } - } - } - -} diff --git a/src/VersionInfo.cs b/src/VersionInfo.cs deleted file mode 100644 index 14581ee..0000000 --- a/src/VersionInfo.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright (c) OpenSim project, http://osgrid.org/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; - -namespace OpenSim -{ - /// - /// - public class VersionInfo - { - public static string Version = "0.0.1-unofficial"; - } -} diff --git a/src/VersionInfo.cs.template b/src/VersionInfo.cs.template deleted file mode 100644 index e4e1b95..0000000 --- a/src/VersionInfo.cs.template +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright (c) OpenSim project, http://osgrid.org/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; - -namespace OpenSim -{ - /// - /// - public class VersionInfo - { - public static string Version = "@@VERSION"; - } -} diff --git a/src/types/Mesh.cs b/src/types/Mesh.cs deleted file mode 100644 index 3e00c91..0000000 --- a/src/types/Mesh.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.types -{ - // TODO: This will need some performance tuning no doubt. - public class Mesh - { - public List mesh; - - public Mesh() - { - mesh = new List(); - } - - public void AddTri(Triangle tri) - { - mesh.Add(tri); - } - - public static Mesh operator +(Mesh a, Mesh b) - { - a.mesh.AddRange(b.mesh); - return a; - } - } -} diff --git a/src/types/Triangle.cs b/src/types/Triangle.cs deleted file mode 100644 index 8dfea6e..0000000 --- a/src/types/Triangle.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Axiom.MathLib; - -namespace OpenSim.types -{ - public class Triangle - { - Vector3 a; - Vector3 b; - Vector3 c; - - public Triangle() - { - a = new Vector3(); - b = new Vector3(); - c = new Vector3(); - } - - public Triangle(Vector3 A, Vector3 B, Vector3 C) - { - a = A; - b = B; - c = C; - } - } -} diff --git a/src/world/Avatar.cs b/src/world/Avatar.cs deleted file mode 100644 index 9d8d7d2..0000000 --- a/src/world/Avatar.cs +++ /dev/null @@ -1,256 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using libsecondlife; -using libsecondlife.Packets; -using Axiom.MathLib; - -namespace OpenSim.world -{ - public class Avatar : Entity - { - public string firstname; - public string lastname; - public OpenSimClient ControllingClient; - public LLVector3 oldvel; - public LLVector3 oldpos; - public uint CurrentKeyMask; - public bool walking; - - private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; - - public Avatar(OpenSimClient TheClient) { - OpenSim_Main.localcons.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); - ControllingClient=TheClient; - SetupTemplate("avatar-template.dat"); - - position = new LLVector3(100.0f,100.0f,60.0f); - } - - public override void update() { - lock(this) { - base.update(); - - oldvel=this.velocity; - oldpos=this.position; - if((this.CurrentKeyMask & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) != 0) { - Vector3 tmpVelocity = this.rotation * new Vector3(1.0f,0.0f,0.0f); - tmpVelocity.Normalize(); tmpVelocity = tmpVelocity * 0.5f; - this.velocity.X = tmpVelocity.x; - this.velocity.Y = tmpVelocity.y; - this.velocity.Z = tmpVelocity.z; - this.walking=true; - } else { - this.velocity.X=0; - this.velocity.Y=0; - this.velocity.Z=0; - this.walking=false; - } - } - } - - private void SetupTemplate(string name) - { - - int i = 0; - FileInfo fInfo = new FileInfo(name); - long numBytes = fInfo.Length; - FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); - BinaryReader br = new BinaryReader(fStream); - byte [] data1 = br.ReadBytes((int)numBytes); - br.Close(); - fStream.Close(); - - libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); - - System.Text.Encoding enc = System.Text.Encoding.ASCII; - libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16); - pos.X = 100f; - objdata.ID = this.localid; - objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); - libsecondlife.LLVector3 pos2 = new LLVector3(100f,100f,23f); - //objdata.FullID=user.AgentID; - byte[] pb = pos.GetBytes(); - Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); - - AvatarTemplate = objdata; - - } - - public void CompleteMovement(World RegionInfo) { - OpenSim_Main.localcons.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet"); - AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); - mov.AgentData.SessionID = this.ControllingClient.SessionID; - mov.AgentData.AgentID = this.ControllingClient.AgentID; - mov.Data.RegionHandle = OpenSim_Main.cfg.RegionHandle; - // TODO - dynamicalise this stuff - mov.Data.Timestamp = 1172750370; - mov.Data.Position = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z); - mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0); - - OpenSim_Main.localcons.WriteLine("Sending AgentMovementComplete packet"); - ControllingClient.OutPacket(mov); - } - - public void SendInitialPosition() { - System.Text.Encoding _enc = System.Text.Encoding.ASCII; - - - //send a objectupdate packet with information about the clients avatar - ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; - objupdate.RegionData.TimeDilation = 64096; - objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; - - objupdate.ObjectData[0] = AvatarTemplate; - //give this avatar object a local id and assign the user a name - objupdate.ObjectData[0].ID = this.localid; - //User_info.name="Test"+this.local_numer+" User"; - objupdate.ObjectData[0].FullID = ControllingClient.AgentID; - objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); - - libsecondlife.LLVector3 pos2 = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z); - - byte[] pb = pos2.GetBytes(); - - Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); - OpenSim_Main.local_world._localNumber++; - this.ControllingClient.OutPacket(objupdate); - } - - public override ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() { - byte[] bytes = new byte[60]; - int i=0; - ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); - - dat.TextureEntry = AvatarTemplate.TextureEntry; - libsecondlife.LLVector3 pos2 = new LLVector3(this.position.X, this.position.Y, this.position.Z); - - uint ID = this.localid; - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); - bytes[i++] = 0; - bytes[i++] = 1; - i += 14; - bytes[i++] = 128; - bytes[i++] = 63; - - byte[] pb = pos2.GetBytes(); - Array.Copy(pb, 0, bytes, i, pb.Length); - i += 12; - - - ushort ac = 32767; - bytes[i++] = (byte)((ushort)(((this.velocity.X/128f)+1)*32767) % 256 ); - bytes[i++] = (byte)(((ushort)(((this.velocity.X/128f)+1)*32767) >> 8) % 256); - bytes[i++] = (byte)((ushort)(((this.velocity.Y/128f)+1)*32767) % 256); - bytes[i++] = (byte)(((ushort)(((this.velocity.Y/128f)+1)*32767) >> 8) % 256); - bytes[i++] = (byte)((ushort)(((this.velocity.Z/128f)+1)*32767) % 256); - bytes[i++] = (byte)(((ushort)(((this.velocity.Z/128f)+1)*32767) >> 8) % 256); - - - - - //accel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - //rot - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - //rotation vel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - dat.Data=bytes; - return(dat); - - } - - public void SendInitialAppearance() { - AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); - aw.AgentData.AgentID = this.ControllingClient.AgentID; - aw.AgentData.SerialNum = 0; - aw.AgentData.SessionID = ControllingClient.SessionID; - - aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; - AgentWearablesUpdatePacket.WearableDataBlock awb = new AgentWearablesUpdatePacket.WearableDataBlock(); - awb.WearableType = (byte)0; - awb.AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); - awb.ItemID = LLUUID.Random(); - aw.WearableData[0] = awb; - - for(int i=1; i<13; i++) { - awb = new AgentWearablesUpdatePacket.WearableDataBlock(); - awb.WearableType = (byte)i; - awb.AssetID = new LLUUID("00000000-0000-0000-0000-000000000000"); - awb.ItemID = new LLUUID("00000000-0000-0000-0000-000000000000"); - aw.WearableData[i] = awb; - } - - ControllingClient.OutPacket(aw); - } - - public void SendRegionHandshake(World RegionInfo) { - OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet"); - System.Text.Encoding _enc = System.Text.Encoding.ASCII; - RegionHandshakePacket handshake = new RegionHandshakePacket(); - - OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details"); - handshake.RegionInfo.BillableFactor = 0; - handshake.RegionInfo.IsEstateManager = false; - handshake.RegionInfo.TerrainHeightRange00 = 60; - handshake.RegionInfo.TerrainHeightRange01 = 60; - handshake.RegionInfo.TerrainHeightRange10 = 60; - handshake.RegionInfo.TerrainHeightRange11 = 60; - handshake.RegionInfo.TerrainStartHeight00 = 10; - handshake.RegionInfo.TerrainStartHeight01 = 10; - handshake.RegionInfo.TerrainStartHeight10 = 10; - handshake.RegionInfo.TerrainStartHeight11 = 10; - handshake.RegionInfo.SimAccess = 13; - handshake.RegionInfo.WaterHeight = 20.0f; - handshake.RegionInfo.RegionFlags = 72458694; // TODO: WTF sirs? Use an enum! - handshake.RegionInfo.SimName = _enc.GetBytes(OpenSim_Main.cfg.RegionName + "\0"); - handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000"); - handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); - handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); - handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); - handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); - handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000"); - handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000"); - handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000"); - handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000"); - handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37"); - - OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet"); - this.ControllingClient.OutPacket(handshake); - } - - public void HandleAgentUpdate(AgentUpdatePacket update) { - lock(this) { - this.CurrentKeyMask = update.AgentData.ControlFlags; - this.rotation = new Quaternion(update.AgentData.BodyRotation.W, update.AgentData.BodyRotation.X, update.AgentData.BodyRotation.Y, update.AgentData.BodyRotation.Z); - this.needupdate = true; - } - } - - } -} diff --git a/src/world/Entity.cs b/src/world/Entity.cs deleted file mode 100644 index 7880a46..0000000 --- a/src/world/Entity.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Axiom.MathLib; -using libsecondlife; -using OpenSim.types; -using libsecondlife.Packets; - -namespace OpenSim.world -{ - public class Entity - { - protected libsecondlife.LLUUID uuid; - protected uint localid; - public LLVector3 position; - public LLVector3 velocity; - protected Quaternion rotation; - protected string name; - protected List children; - public bool needupdate; - - public Entity() - { - uuid = new libsecondlife.LLUUID(); - localid = 8880000 + (OpenSim_Main.local_world._localNumber++); // FIXME - race condition! - position = new LLVector3(); - velocity = new LLVector3(); - rotation = new Quaternion(); - name = "(basic entity)"; - children = new List(); - } - - public virtual void update() { - // Do any per-frame updates needed that are applicable to every type of entity - foreach (Entity child in children) - { - if(child.needupdate) - child.update(); - } - this.needupdate=false; - } - - public virtual ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() { - return null; - } - - - public virtual string getName() - { - return name; - } - - public virtual Mesh getMesh() - { - Mesh mesh = new Mesh(); - - foreach (Entity child in children) - { - mesh += child.getMesh(); - } - - return mesh; - } - } -} diff --git a/src/world/HeightmapGenHills.cs b/src/world/HeightmapGenHills.cs deleted file mode 100644 index 12af005..0000000 --- a/src/world/HeightmapGenHills.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System; - -namespace libsecondlife -{ - public class HeightmapGenHills - { - private Random Rand = new Random(); - private int NumHills; - private float HillMin; - private float HillMax; - private bool Island; - private float[] heightmap; - - public float[] GenerateHeightmap(int numHills, float hillMin, float hillMax, bool island) - { - NumHills = numHills; - HillMin = hillMin; - HillMax = hillMax; - Island = island; - - heightmap = new float[256 * 256]; - - for (int i = 0; i < numHills; i++) - { - AddHill(); - } - - Normalize(); - - return heightmap; - } - - private void AddHill() - { - float x, y; - float radius = RandomRange(HillMin, HillMax); - - if (Island) - { - // Which direction from the center of the map the hill is placed - float theta = RandomRange(0, 6.28f); - - // How far from the center of the map to place the hill. The radius - // is subtracted from the range to prevent any part of the hill from - // reaching the edge of the map - float distance = RandomRange(radius / 2.0f, 128.0f - radius); - - x = 128.0f + (float)Math.Cos(theta) * distance; - y = 128.0f + (float)Math.Sin(theta) * distance; - } - else - { - x = RandomRange(-radius, 256.0f + radius); - y = RandomRange(-radius, 256.0f + radius); - } - - float radiusSq = radius * radius; - float distSq; - float height; - - int xMin = (int)(x - radius) - 1; - int xMax = (int)(x + radius) + 1; - if (xMin < 0) xMin = 0; - if (xMax > 255) xMax = 255; - - int yMin = (int)(y - radius) - 1; - int yMax = (int)(y + radius) + 1; - if (yMin < 0) yMin = 0; - if (yMax > 255) yMax = 255; - - // Loop through each affected cell and determine the height at that point - for (int v = yMin; v <= yMax; ++v) - { - float fv = (float)v; - - for (int h = xMin; h <= xMax; ++h) - { - float fh = (float)h; - - // Determine how far from the center of this hill this point is - distSq = (x - fh) * (x - fh) + (y - fv) * (y - fv); - height = radiusSq - distSq; - - // Don't add negative hill values - if (height > 0.0f) heightmap[h + v * 256] += height; - } - } - } - - private void Normalize() - { - float min = heightmap[0]; - float max = heightmap[0]; - - for (int x = 0; x < 256; x++) - { - for (int y = 0; y < 256; y++) - { - if (heightmap[x + y * 256] < min) min = heightmap[x + y * 256]; - if (heightmap[x + y * 256] > max) max = heightmap[x + y * 256]; - } - } - - // Avoid a rare divide by zero - if (min != max) - { - for (int x = 0; x < 256; x++) - { - for (int y = 0; y < 256; y++) - { - heightmap[x + y * 256] = ((heightmap[x + y * 256] - min) / (max - min)) * (HillMax - HillMin); - } - } - } - } - - private float RandomRange(float min, float max) - { - return (float)Rand.NextDouble() * (max - min) + min; - } - } -} diff --git a/src/world/PhysicsEngine.cs b/src/world/PhysicsEngine.cs deleted file mode 100644 index b237f5e..0000000 --- a/src/world/PhysicsEngine.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Threading; -using libsecondlife; -using libsecondlife.Packets; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.world -{ - public class PhysicsEngine - { - - public PhysicsEngine() { - } - - public void Startup() { - OpenSim_Main.localcons.WriteLine("PhysicsEngine.cs:Startup() - DOING NOTHING, DUMMY FUNCTION!"); - } - - public void DoStuff(World simworld) { - foreach (libsecondlife.LLUUID UUID in simworld.Entities.Keys) - { - simworld.Entities[UUID].position += simworld.Entities[UUID].velocity; - simworld.Entities[UUID].position.Z = simworld.LandMap[(int)simworld.Entities[UUID].position.Y * 256 + (int)simworld.Entities[UUID].position.X]+1; - if(simworld.Entities[UUID].position.X<0) simworld.Entities[UUID].position.X=0; - if(simworld.Entities[UUID].position.Y<0) simworld.Entities[UUID].position.Y=0; - if(simworld.Entities[UUID].position.X>255) simworld.Entities[UUID].position.X=255; - if(simworld.Entities[UUID].position.Y>255) simworld.Entities[UUID].position.Y=255; - } - } - } -} diff --git a/src/world/Primitive.cs b/src/world/Primitive.cs deleted file mode 100644 index 143fa55..0000000 --- a/src/world/Primitive.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.types; - -namespace OpenSim.world -{ - public class Primitive : Entity - { - protected float mesh_cutbegin; - protected float mesh_cutend; - - public Primitive() - { - mesh_cutbegin = 0.0f; - mesh_cutend = 1.0f; - } - - public override Mesh getMesh() - { - Mesh mesh = new Mesh(); - Triangle tri = new Triangle( - new Axiom.MathLib.Vector3(0.0f, 1.0f, 1.0f), - new Axiom.MathLib.Vector3(1.0f, 0.0f, 1.0f), - new Axiom.MathLib.Vector3(1.0f, 1.0f, 0.0f)); - - mesh.AddTri(tri); - mesh += base.getMesh(); - - return mesh; - } - } -} diff --git a/src/world/ScriptEngine.cs b/src/world/ScriptEngine.cs deleted file mode 100644 index f20a08e..0000000 --- a/src/world/ScriptEngine.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.world -{ - public class ScriptEngine - { - public ScriptEngine(World env) - { - } - - public void LoadScript() - { - - } - } -} diff --git a/src/world/SurfacePatch.cs b/src/world/SurfacePatch.cs deleted file mode 100644 index 71e4116..0000000 --- a/src/world/SurfacePatch.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.world -{ - public class SurfacePatch - { - public float[] HeightMap; - - public SurfacePatch() { - HeightMap = new float[16*16]; - - int xinc; - int yinc; - for(xinc=0; xinc<16; xinc++) for(yinc=0; yinc<16; yinc++) { - HeightMap[xinc+(yinc*16)]=100.0f; - } - - } - } -} diff --git a/src/world/World.cs b/src/world/World.cs deleted file mode 100644 index 158ddc2..0000000 --- a/src/world/World.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using System.Threading; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using libsecondlife.Packets; - -namespace OpenSim.world -{ - public class World - { - public Dictionary Entities; - public float[] LandMap; - public ScriptEngine Scripts; - public uint _localNumber = 0; - public PhysicsEngine physics; - - private libsecondlife.TerrainManager TerrainManager; - private Random Rand = new Random(); - - public World() - { - OpenSim_Main.localcons.WriteLine("World.cs - creating new entitities instance"); - Entities = new Dictionary(); - - OpenSim_Main.localcons.WriteLine("World.cs - creating LandMap"); - TerrainManager = new TerrainManager(new SecondLife()); - } - - public void InitLoop() - { - OpenSim_Main.localcons.WriteLine("World.cs:StartLoop() - Initialising physics"); - this.physics = new PhysicsEngine(); - physics.Startup(); - } - - public void DoStuff() - { - lock (this) - { - physics.DoStuff(this); - this.Update(); - } - } - - public void Update() - { - foreach (libsecondlife.LLUUID UUID in Entities.Keys) - { - if (Entities[UUID].needupdate) - { - Entities[UUID].update(); - - if (Entities[UUID] is Avatar) - { - Avatar avatar = (Avatar)Entities[UUID]; - if ((avatar.oldpos != avatar.position) || (avatar.oldvel != avatar.velocity) || avatar.walking) - { - ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = Entities[UUID].CreateTerseBlock(); - foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) - { - ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME - terse.RegionData.TimeDilation = 0; - terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; - terse.ObjectData[0] = terseBlock; - client.OutPacket(terse); - } - } - } - } - } - } - - public void SendLayerData(OpenSimClient RemoteClient) - { - int[] patches = new int[4]; - - for (int y = 0; y < 16; y++) - { - for (int x = 0; x < 16; x = x + 4) - { - patches[0] = x + 0 + y * 16; - patches[1] = x + 1 + y * 16; - patches[2] = x + 2 + y * 16; - patches[3] = x + 3 + y * 16; - - Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches); - RemoteClient.OutPacket(layerpack); - } - } - } - - public void AddViewerAgent(OpenSimClient AgentClient) - { - OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); - Avatar NewAvatar = new Avatar(AgentClient); - OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); - this.Entities.Add(AgentClient.AgentID, NewAvatar); - OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); - NewAvatar.SendRegionHandshake(this); - this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user - } - - public bool Backup() - { - /* TODO: Save the current world entities state. */ - - return false; - } - } -} diff --git a/src/world/scripting/IScript.cs b/src/world/scripting/IScript.cs deleted file mode 100644 index 550594d..0000000 --- a/src/world/scripting/IScript.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.world.scripting -{ - public interface IScriptHost { - bool Register(IScript iscript); - } - public interface IScript - { - string Name{get;set;} - IScriptHost Host{get;set;} - void Show(); - } -} -- cgit v1.1