diff options
author | gareth | 2007-03-07 18:48:38 +0000 |
---|---|---|
committer | gareth | 2007-03-07 18:48:38 +0000 |
commit | b3844c1f7348b4296b5ab1df258935d7f971e412 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /src | |
parent | * Updating libsecondlife.dll to the latest version with a working LayerData f... (diff) | |
download | opensim-SC-b3844c1f7348b4296b5ab1df258935d7f971e412.zip opensim-SC-b3844c1f7348b4296b5ab1df258935d7f971e412.tar.gz opensim-SC-b3844c1f7348b4296b5ab1df258935d7f971e412.tar.bz2 opensim-SC-b3844c1f7348b4296b5ab1df258935d7f971e412.tar.xz |
Deleted old trunk code
Diffstat (limited to '')
-rw-r--r-- | src/Config.cs | 174 | ||||
-rw-r--r-- | src/Main.cs | 159 | ||||
-rw-r--r-- | src/OpenSimClient.cs | 510 | ||||
-rw-r--r-- | src/Second-server.csproj | 65 | ||||
-rw-r--r-- | src/Second-server.sln | 26 | ||||
-rw-r--r-- | src/ServerConsole.cs | 195 | ||||
-rw-r--r-- | src/Util.cs | 75 | ||||
-rw-r--r-- | src/VersionInfo.cs | 37 | ||||
-rw-r--r-- | src/VersionInfo.cs.template | 37 | ||||
-rw-r--r-- | src/types/Mesh.cs | 28 | ||||
-rw-r--r-- | src/types/Triangle.cs | 28 | ||||
-rw-r--r-- | src/world/Avatar.cs | 256 | ||||
-rw-r--r-- | src/world/Entity.cs | 65 | ||||
-rw-r--r-- | src/world/HeightmapGenHills.cs | 122 | ||||
-rw-r--r-- | src/world/PhysicsEngine.cs | 32 | ||||
-rw-r--r-- | src/world/Primitive.cs | 33 | ||||
-rw-r--r-- | src/world/ScriptEngine.cs | 18 | ||||
-rw-r--r-- | src/world/SurfacePatch.cs | 22 | ||||
-rw-r--r-- | src/world/World.cs | 112 | ||||
-rw-r--r-- | src/world/scripting/IScript.cs | 16 |
20 files changed, 0 insertions, 2010 deletions
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 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://osgrid.org/ | ||
3 | |||
4 | * Copyright (c) <year>, <copyright holder> | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions are met: | ||
9 | * * Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * * Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * * Neither the name of the <organization> nor the | ||
15 | * names of its contributors may be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
19 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
21 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | using System; | ||
31 | using System.Collections.Generic; | ||
32 | using System.IO; | ||
33 | using Db4objects.Db4o; | ||
34 | using libsecondlife; | ||
35 | using OpenSim.world; | ||
36 | |||
37 | namespace OpenSim | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// This class handles connection to the underlying database used for configuration of the region. | ||
41 | /// Region content is also stored by this class. The main entry point is InitConfig() which attempts to locate | ||
42 | /// opensim.yap in the current working directory. If opensim.yap can not be found, default settings are loaded from | ||
43 | /// what is hardcoded here and then saved into opensim.yap for future startups. | ||
44 | /// </summary> | ||
45 | public class SimConfig | ||
46 | { | ||
47 | public string RegionName; | ||
48 | |||
49 | public uint RegionLocX; | ||
50 | public uint RegionLocY; | ||
51 | public ulong RegionHandle; | ||
52 | |||
53 | public int IPListenPort; | ||
54 | public string IPListenAddr; | ||
55 | |||
56 | public bool sandbox = true; | ||
57 | public string AssetURL = String.Empty; | ||
58 | public string AssetSendKey = String.Empty; | ||
59 | |||
60 | public string GridURL = String.Empty; | ||
61 | public string GridSendKey = String.Empty; | ||
62 | |||
63 | private IObjectContainer db; | ||
64 | |||
65 | public void LoadDefaults() | ||
66 | { | ||
67 | string tempstring; | ||
68 | OpenSim_Main.localcons.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings"); | ||
69 | |||
70 | this.RegionName = OpenSim_Main.localcons.CmdPrompt("Name [OpenSim test]: ", "OpenSim test"); | ||
71 | this.RegionLocX = (uint)Convert.ToInt32(OpenSim_Main.localcons.CmdPrompt("Grid Location X [997]: ", "997")); | ||
72 | this.RegionLocY = (uint)Convert.ToInt32(OpenSim_Main.localcons.CmdPrompt("Grid Location Y [996]: ", "996")); | ||
73 | this.IPListenPort = Convert.ToInt32(OpenSim_Main.localcons.CmdPrompt("UDP port for client connections [9000]: ", "9000")); | ||
74 | this.IPListenAddr = OpenSim_Main.localcons.CmdPrompt("IP Address to listen on for client connections [127.0.0.1]: ", "127.0.0.1"); | ||
75 | |||
76 | tempstring = OpenSim_Main.localcons.CmdPrompt("Run in sandbox or grid mode? [sandbox]: ", "sandbox", "sandbox", "grid"); | ||
77 | this.sandbox = tempstring.Equals("sandbox"); | ||
78 | |||
79 | if (!this.sandbox) | ||
80 | { | ||
81 | this.AssetURL = OpenSim_Main.localcons.CmdPrompt("Asset server URL: "); | ||
82 | this.AssetSendKey = OpenSim_Main.localcons.CmdPrompt("Asset server key: "); | ||
83 | this.GridURL = OpenSim_Main.localcons.CmdPrompt("Grid server URL: "); | ||
84 | this.GridSendKey = OpenSim_Main.localcons.CmdPrompt("Grid server key: "); | ||
85 | } | ||
86 | this.RegionHandle = Helpers.UIntsToLong((RegionLocX * 256), (RegionLocY * 256)); | ||
87 | } | ||
88 | |||
89 | public void InitConfig() | ||
90 | { | ||
91 | try | ||
92 | { | ||
93 | db = Db4oFactory.OpenFile("opensim.yap"); | ||
94 | IObjectSet result = db.Get(typeof(SimConfig)); | ||
95 | if (result.Count == 1) | ||
96 | { | ||
97 | OpenSim_Main.localcons.WriteLine("Config.cs:InitConfig() - Found a SimConfig object in the local database, loading"); | ||
98 | foreach (SimConfig cfg in result) | ||
99 | { | ||
100 | this.sandbox = cfg.sandbox; | ||
101 | this.RegionName = cfg.RegionName; | ||
102 | this.RegionLocX = cfg.RegionLocX; | ||
103 | this.RegionLocY = cfg.RegionLocY; | ||
104 | this.RegionHandle = Helpers.UIntsToLong((RegionLocX * 256), (RegionLocY * 256)); | ||
105 | this.IPListenPort = cfg.IPListenPort; | ||
106 | this.IPListenAddr = cfg.IPListenAddr; | ||
107 | this.AssetURL = cfg.AssetURL; | ||
108 | this.AssetSendKey = cfg.AssetSendKey; | ||
109 | this.GridURL = cfg.GridURL; | ||
110 | this.GridSendKey = cfg.GridSendKey; | ||
111 | } | ||
112 | } | ||
113 | else | ||
114 | { | ||
115 | OpenSim_Main.localcons.WriteLine("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults"); | ||
116 | LoadDefaults(); | ||
117 | OpenSim_Main.localcons.WriteLine("Writing out default settings to local database"); | ||
118 | db.Set(this); | ||
119 | } | ||
120 | } | ||
121 | catch (Exception e) | ||
122 | { | ||
123 | db.Close(); | ||
124 | OpenSim_Main.localcons.WriteLine("Config.cs:InitConfig() - Exception occured"); | ||
125 | OpenSim_Main.localcons.WriteLine(e.ToString()); | ||
126 | } | ||
127 | OpenSim_Main.localcons.WriteLine("Sim settings loaded:"); | ||
128 | OpenSim_Main.localcons.WriteLine("Name: " + this.RegionName); | ||
129 | OpenSim_Main.localcons.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); | ||
130 | OpenSim_Main.localcons.WriteLine("Region Handle: " + this.RegionHandle.ToString()); | ||
131 | OpenSim_Main.localcons.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort); | ||
132 | OpenSim_Main.localcons.WriteLine("Sandbox Mode? " + this.sandbox.ToString()); | ||
133 | OpenSim_Main.localcons.WriteLine("Asset URL: " + this.AssetURL); | ||
134 | OpenSim_Main.localcons.WriteLine("Asset key: " + this.AssetSendKey); | ||
135 | OpenSim_Main.localcons.WriteLine("Grid URL: " + this.GridURL); | ||
136 | OpenSim_Main.localcons.WriteLine("Grid key: " + this.GridSendKey); | ||
137 | } | ||
138 | |||
139 | public World LoadWorld() | ||
140 | { | ||
141 | OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - Loading world...."); | ||
142 | World blank = new World(); | ||
143 | OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - Looking for a heightmap in local DB"); | ||
144 | IObjectSet world_result = db.Get(new float[65536]); | ||
145 | if (world_result.Count > 0) | ||
146 | { | ||
147 | OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - Found a heightmap in local database, loading"); | ||
148 | blank.LandMap = (float[])world_result.Next(); | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - No heightmap found, generating new one"); | ||
153 | HeightmapGenHills hills = new HeightmapGenHills(); | ||
154 | blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); | ||
155 | |||
156 | OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - Saving heightmap to local database"); | ||
157 | db.Set(blank.LandMap); | ||
158 | db.Commit(); | ||
159 | } | ||
160 | return blank; | ||
161 | } | ||
162 | |||
163 | public void LoadFromGrid() | ||
164 | { | ||
165 | OpenSim_Main.localcons.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!"); | ||
166 | // TODO: Make this crap work | ||
167 | } | ||
168 | |||
169 | public void Shutdown() | ||
170 | { | ||
171 | db.Close(); | ||
172 | } | ||
173 | } | ||
174 | } | ||
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 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://osgrid.org/ | ||
3 | |||
4 | |||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions are met: | ||
9 | * * Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * * Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * * Neither the name of the <organization> nor the | ||
15 | * names of its contributors may be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
19 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
21 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | using System; | ||
31 | using System.Text; | ||
32 | using System.IO; | ||
33 | using System.Threading; | ||
34 | using System.Net; | ||
35 | using System.Net.Sockets; | ||
36 | using System.Collections; | ||
37 | using System.Collections.Generic; | ||
38 | using libsecondlife; | ||
39 | using libsecondlife.Packets; | ||
40 | using OpenSim.world; | ||
41 | |||
42 | namespace OpenSim | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// Description of MainForm. | ||
46 | /// </summary> | ||
47 | public class OpenSim_Main | ||
48 | { | ||
49 | public static DateTime startuptime; | ||
50 | public static OpenSim_Main sim; | ||
51 | public static SimConfig cfg; | ||
52 | public static World local_world; | ||
53 | public static ServerConsole localcons; | ||
54 | private static Thread MainListener; | ||
55 | public static Socket Server; | ||
56 | private static IPEndPoint ServerIncoming; | ||
57 | private static byte[] RecvBuffer = new byte[4096]; | ||
58 | private byte[] ZeroBuffer = new byte[8192]; | ||
59 | private static IPEndPoint ipeSender; | ||
60 | private static EndPoint epSender; | ||
61 | private static AsyncCallback ReceivedData; | ||
62 | public Dictionary<EndPoint, OpenSimClient> ClientThreads = new Dictionary<EndPoint, OpenSimClient>(); | ||
63 | |||
64 | [STAThread] | ||
65 | public static void Main( string[] args ) | ||
66 | { | ||
67 | Console.WriteLine("OpenSim " + VersionInfo.Version + "\n"); | ||
68 | Console.WriteLine("Starting...\n"); | ||
69 | sim = new OpenSim_Main(); | ||
70 | sim.Startup(); | ||
71 | while(true) { | ||
72 | localcons.MainConsolePrompt(); | ||
73 | } | ||
74 | } | ||
75 | |||
76 | private OpenSim_Main() { | ||
77 | } | ||
78 | |||
79 | public static void Shutdown() { | ||
80 | localcons.WriteLine("Main.cs:Shutdown() - Closing all threads"); | ||
81 | localcons.WriteLine("Main.cs:Shutdown() - Killing listener thread"); | ||
82 | MainListener.Abort(); | ||
83 | localcons.WriteLine("Main.cs:Shutdown() - Killing clients"); | ||
84 | // IMPLEMENT THIS | ||
85 | localcons.WriteLine("Main.cs:Shutdown() - Closing console and terminating"); | ||
86 | localcons.Close(); | ||
87 | Environment.Exit(0); | ||
88 | } | ||
89 | |||
90 | private void Startup() { | ||
91 | startuptime=DateTime.Now; | ||
92 | localcons=new ServerConsole(ServerConsole.ConsoleType.Local,"",0); | ||
93 | // We check our local database first, then the grid for config options | ||
94 | localcons.WriteLine("Main.cs:Startup() - Loading configuration"); | ||
95 | cfg = new SimConfig(); | ||
96 | cfg.InitConfig(); | ||
97 | localcons.WriteLine("Main.cs:Startup() - Contacting gridserver"); | ||
98 | cfg.LoadFromGrid(); | ||
99 | |||
100 | localcons.WriteLine("Main.cs:Startup() - We are " + cfg.RegionName + " at " + cfg.RegionLocX.ToString() + "," + cfg.RegionLocY.ToString()); | ||
101 | localcons.WriteLine("Initialising world"); | ||
102 | local_world = cfg.LoadWorld(); | ||
103 | |||
104 | localcons.WriteLine("Main.cs:Startup() - Starting up main world loop"); | ||
105 | local_world.InitLoop(); | ||
106 | |||
107 | localcons.WriteLine("Main.cs:Startup() - Starting up messaging system"); | ||
108 | MainListener = new Thread(new ThreadStart(MainServerListener)); | ||
109 | MainListener.Start(); | ||
110 | |||
111 | Thread.Sleep(500); // give other threads a chance to catch up | ||
112 | string[] noparams = new string[1]; | ||
113 | noparams[0]=""; | ||
114 | localcons.WriteLine("\nOpenSim ready\nType help for list of commands"); | ||
115 | } | ||
116 | |||
117 | private void OnReceivedData(IAsyncResult result) { | ||
118 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | ||
119 | epSender = (EndPoint)ipeSender; | ||
120 | Packet packet = null; | ||
121 | int numBytes = Server.EndReceiveFrom(result, ref epSender); | ||
122 | int packetEnd = numBytes - 1; | ||
123 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); | ||
124 | |||
125 | // This is either a new client or a packet to send to an old one | ||
126 | if(ClientThreads.ContainsKey(epSender)) { | ||
127 | ClientThreads[epSender].InPacket(packet); | ||
128 | } else if( packet.Type == PacketType.UseCircuitCode ) { // new client | ||
129 | OpenSimClient newuser = new OpenSimClient(epSender,(UseCircuitCodePacket)packet); | ||
130 | ClientThreads.Add(epSender, newuser); | ||
131 | } else { // invalid client | ||
132 | Console.Error.WriteLine("Main.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString()); | ||
133 | } | ||
134 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | ||
135 | } | ||
136 | |||
137 | private void MainServerListener() { | ||
138 | localcons.WriteLine("Main.cs:MainServerListener() - New thread started"); | ||
139 | localcons.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + cfg.IPListenAddr + ":" + cfg.IPListenPort); | ||
140 | |||
141 | ServerIncoming = new IPEndPoint(IPAddress.Any, cfg.IPListenPort); | ||
142 | Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); | ||
143 | Server.Bind(ServerIncoming); | ||
144 | |||
145 | localcons.WriteLine("Main.cs:MainServerListener() - UDP socket bound, getting ready to listen"); | ||
146 | |||
147 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | ||
148 | epSender = (EndPoint) ipeSender; | ||
149 | ReceivedData = new AsyncCallback(this.OnReceivedData); | ||
150 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | ||
151 | |||
152 | localcons.WriteLine("Main.cs:MainServerListener() - Listening..."); | ||
153 | while(true) { | ||
154 | Thread.Sleep(100); | ||
155 | local_world.DoStuff(); | ||
156 | } | ||
157 | } | ||
158 | } | ||
159 | } | ||
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 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://osgrid.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | using System; | ||
28 | using System.Collections; | ||
29 | using System.Collections.Generic; | ||
30 | using libsecondlife; | ||
31 | using libsecondlife.Packets; | ||
32 | using System.Net; | ||
33 | using System.Net.Sockets; | ||
34 | using System.IO; | ||
35 | using System.Threading; | ||
36 | using System.Timers; | ||
37 | |||
38 | namespace OpenSim | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// Handles new client connections | ||
42 | /// Constructor takes a single Packet and authenticates everything | ||
43 | /// </summary> | ||
44 | public class OpenSimClient | ||
45 | { | ||
46 | |||
47 | public LLUUID AgentID; | ||
48 | public LLUUID SessionID; | ||
49 | public uint CircuitCode; | ||
50 | public world.Avatar ClientAvatar; | ||
51 | private UseCircuitCodePacket cirpack; | ||
52 | private Thread ClientThread; | ||
53 | public EndPoint userEP; | ||
54 | private BlockingQueue<QueItem> PacketQueue; | ||
55 | private BlockingQueue<TransferRequestPacket> AssetRequests; | ||
56 | private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); | ||
57 | private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); | ||
58 | private System.Timers.Timer AckTimer; | ||
59 | private uint Sequence = 0; | ||
60 | private object SequenceLock = new object(); | ||
61 | private const int MAX_APPENDED_ACKS = 10; | ||
62 | private const int RESEND_TIMEOUT = 4000; | ||
63 | private const int MAX_SEQUENCE = 0xFFFFFF; | ||
64 | //private Queue<uint> Inbox; | ||
65 | |||
66 | public void ack_pack(Packet Pack) | ||
67 | { | ||
68 | //libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket(); | ||
69 | //ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; | ||
70 | //ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); | ||
71 | //ack_it.Packets[0].ID = Pack.Header.ID; | ||
72 | //ack_it.Header.Reliable = false; | ||
73 | |||
74 | //OutPacket(ack_it); | ||
75 | |||
76 | if (Pack.Header.Reliable) | ||
77 | { | ||
78 | lock (PendingAcks) | ||
79 | { | ||
80 | uint sequence = (uint)Pack.Header.Sequence; | ||
81 | if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; } | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | |||
86 | public void AssetLoader() | ||
87 | { | ||
88 | if (OpenSim_Main.cfg.sandbox == false) | ||
89 | { | ||
90 | WebResponse AssetResponse; | ||
91 | byte[] idata; | ||
92 | |||
93 | OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AssetLoader() - Starting new thread"); | ||
94 | TransferRequestPacket reqPacket = AssetRequests.Dequeue(); | ||
95 | OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AssetLoader() - Got a request, processing it"); | ||
96 | LLUUID AssetID = new LLUUID(reqPacket.TransferInfo.Params, 0); | ||
97 | |||
98 | try | ||
99 | { | ||
100 | WebRequest AssetLoad = WebRequest.Create(OpenSim_Main.cfg.AssetURL + "getasset/" + OpenSim_Main.cfg.AssetSendKey + "/" + AssetID + "/data"); | ||
101 | AssetResponse = AssetLoad.GetResponse(); | ||
102 | idata = new byte[(int)AssetResponse.ContentLength]; | ||
103 | BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream()); | ||
104 | idata = br.ReadBytes((int)AssetResponse.ContentLength); | ||
105 | br.Close(); | ||
106 | } | ||
107 | catch (Exception e) | ||
108 | { | ||
109 | Console.WriteLine(e.ToString()); | ||
110 | return; | ||
111 | } | ||
112 | |||
113 | TransferInfoPacket Transfer = new TransferInfoPacket(); | ||
114 | Transfer.TransferInfo.ChannelType = 2; | ||
115 | Transfer.TransferInfo.Status = 0; | ||
116 | Transfer.TransferInfo.TargetType = 0; | ||
117 | Transfer.TransferInfo.Params = reqPacket.TransferInfo.Params; | ||
118 | Transfer.TransferInfo.Size = (int)AssetResponse.ContentLength; | ||
119 | Transfer.TransferInfo.TransferID = reqPacket.TransferInfo.TransferID; | ||
120 | |||
121 | OutPacket(Transfer); | ||
122 | |||
123 | TransferPacketPacket TransferPacket = new TransferPacketPacket(); | ||
124 | TransferPacket.TransferData.Packet = 0; | ||
125 | TransferPacket.TransferData.ChannelType = 2; | ||
126 | TransferPacket.TransferData.TransferID = reqPacket.TransferInfo.TransferID; | ||
127 | |||
128 | if (AssetResponse.ContentLength > 1000) | ||
129 | { | ||
130 | byte[] chunk = new byte[1000]; | ||
131 | Array.Copy(idata, chunk, 1000); | ||
132 | TransferPacket.TransferData.Data = chunk; | ||
133 | TransferPacket.TransferData.Status = 0; | ||
134 | OutPacket(TransferPacket); | ||
135 | |||
136 | TransferPacket = new TransferPacketPacket(); | ||
137 | TransferPacket.TransferData.Packet = 1; | ||
138 | TransferPacket.TransferData.ChannelType = 2; | ||
139 | TransferPacket.TransferData.TransferID = reqPacket.TransferInfo.TransferID; | ||
140 | byte[] chunk1 = new byte[(idata.Length - 1000)]; | ||
141 | Array.Copy(idata, 1000, chunk1, 0, chunk1.Length); | ||
142 | TransferPacket.TransferData.Data = chunk1; | ||
143 | TransferPacket.TransferData.Status = 1; | ||
144 | OutPacket(TransferPacket); | ||
145 | } | ||
146 | else | ||
147 | { | ||
148 | TransferPacket.TransferData.Status = 1; | ||
149 | TransferPacket.TransferData.Data = idata; | ||
150 | OutPacket(TransferPacket); | ||
151 | } | ||
152 | AssetResponse.Close(); | ||
153 | } | ||
154 | } | ||
155 | |||
156 | public void Logout() | ||
157 | { | ||
158 | // TODO - kill any AssetLoaders | ||
159 | ClientThread.Abort(); | ||
160 | } | ||
161 | |||
162 | public void ProcessInPacket(Packet Pack) | ||
163 | { | ||
164 | ack_pack(Pack); | ||
165 | switch (Pack.Type) | ||
166 | { | ||
167 | case PacketType.CompleteAgentMovement: | ||
168 | ClientAvatar.CompleteMovement(OpenSim_Main.local_world); | ||
169 | ClientAvatar.SendInitialPosition(); | ||
170 | break; | ||
171 | case PacketType.RegionHandshakeReply: | ||
172 | OpenSim_Main.local_world.SendLayerData(this); | ||
173 | break; | ||
174 | case PacketType.AgentWearablesRequest: | ||
175 | ClientAvatar.SendInitialAppearance(); | ||
176 | break; | ||
177 | case PacketType.TransferRequest: | ||
178 | OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); | ||
179 | // We put transfer requests into a big queue and then spawn a thread for each new one | ||
180 | TransferRequestPacket transfer = (TransferRequestPacket)Pack; | ||
181 | AssetRequests.Enqueue(transfer); | ||
182 | Thread AssetLoaderThread = new Thread(new ThreadStart(AssetLoader)); | ||
183 | AssetLoaderThread.Start(); | ||
184 | break; | ||
185 | case PacketType.LogoutRequest: | ||
186 | OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request"); | ||
187 | lock (OpenSim_Main.local_world.Entities) | ||
188 | { | ||
189 | OpenSim_Main.local_world.Entities.Remove(this.AgentID); | ||
190 | } | ||
191 | |||
192 | if (OpenSim_Main.cfg.sandbox == false) | ||
193 | { | ||
194 | WebRequest DeleteSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + this.AgentID.ToString() + this.CircuitCode.ToString() + "/delete"); | ||
195 | WebResponse GridResponse = DeleteSession.GetResponse(); | ||
196 | StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); | ||
197 | String grTest = sr.ReadLine(); | ||
198 | sr.Close(); | ||
199 | GridResponse.Close(); | ||
200 | OpenSim_Main.localcons.WriteLine("DEBUG: " + grTest); | ||
201 | } | ||
202 | this.ClientThread.Abort(); | ||
203 | break; | ||
204 | case PacketType.AgentUpdate: | ||
205 | ClientAvatar.HandleAgentUpdate((AgentUpdatePacket)Pack); | ||
206 | break; | ||
207 | case PacketType.ChatFromViewer: | ||
208 | ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; | ||
209 | if (Helpers.FieldToString(inchatpack.ChatData.Message) == "") break; | ||
210 | |||
211 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
212 | libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); | ||
213 | reply.ChatData.Audible = 1; | ||
214 | reply.ChatData.Message = inchatpack.ChatData.Message; | ||
215 | reply.ChatData.ChatType = 1; | ||
216 | reply.ChatData.SourceType = 1; | ||
217 | reply.ChatData.Position = this.ClientAvatar.position; | ||
218 | reply.ChatData.FromName = _enc.GetBytes(this.ClientAvatar.firstname + " " + this.ClientAvatar.lastname + "\0"); | ||
219 | reply.ChatData.OwnerID = this.AgentID; | ||
220 | reply.ChatData.SourceID = this.AgentID; | ||
221 | |||
222 | |||
223 | |||
224 | foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) | ||
225 | { | ||
226 | client.OutPacket(reply); | ||
227 | } | ||
228 | break; | ||
229 | } | ||
230 | } | ||
231 | |||
232 | private void ResendUnacked() | ||
233 | { | ||
234 | int now = Environment.TickCount; | ||
235 | |||
236 | lock (NeedAck) | ||
237 | { | ||
238 | foreach (Packet packet in NeedAck.Values) | ||
239 | { | ||
240 | if (now - packet.TickCount > RESEND_TIMEOUT) | ||
241 | { | ||
242 | |||
243 | packet.Header.Resent = true; | ||
244 | OutPacket(packet); | ||
245 | } | ||
246 | } | ||
247 | } | ||
248 | } | ||
249 | |||
250 | private void SendAcks() | ||
251 | { | ||
252 | lock (PendingAcks) | ||
253 | { | ||
254 | if (PendingAcks.Count > 0) | ||
255 | { | ||
256 | if (PendingAcks.Count > 250) | ||
257 | { | ||
258 | return; | ||
259 | } | ||
260 | |||
261 | |||
262 | |||
263 | int i = 0; | ||
264 | PacketAckPacket acks = new PacketAckPacket(); | ||
265 | acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; | ||
266 | |||
267 | foreach (uint ack in PendingAcks.Values) | ||
268 | { | ||
269 | acks.Packets[i] = new PacketAckPacket.PacketsBlock(); | ||
270 | acks.Packets[i].ID = ack; | ||
271 | i++; | ||
272 | } | ||
273 | |||
274 | acks.Header.Reliable = false; | ||
275 | OutPacket(acks); | ||
276 | |||
277 | PendingAcks.Clear(); | ||
278 | } | ||
279 | } | ||
280 | } | ||
281 | |||
282 | private void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) | ||
283 | { | ||
284 | SendAcks(); | ||
285 | ResendUnacked(); | ||
286 | } | ||
287 | |||
288 | public void ProcessOutPacket(Packet Pack) | ||
289 | { | ||
290 | |||
291 | // Keep track of when this packet was sent out | ||
292 | Pack.TickCount = Environment.TickCount; | ||
293 | |||
294 | if (!Pack.Header.Resent) | ||
295 | { | ||
296 | // Set the sequence number | ||
297 | lock (SequenceLock) | ||
298 | { | ||
299 | if (Sequence >= MAX_SEQUENCE) | ||
300 | Sequence = 1; | ||
301 | else | ||
302 | Sequence++; | ||
303 | Pack.Header.Sequence = Sequence; | ||
304 | } | ||
305 | |||
306 | if (Pack.Header.Reliable) //DIRTY HACK | ||
307 | { | ||
308 | lock (NeedAck) | ||
309 | { | ||
310 | if (!NeedAck.ContainsKey(Pack.Header.Sequence)) | ||
311 | { | ||
312 | NeedAck.Add(Pack.Header.Sequence, Pack); | ||
313 | } | ||
314 | else | ||
315 | { | ||
316 | // Client.Log("Attempted to add a duplicate sequence number (" + | ||
317 | // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + | ||
318 | // packet.Type.ToString(), Helpers.LogLevel.Warning); | ||
319 | } | ||
320 | } | ||
321 | |||
322 | // Don't append ACKs to resent packets, in case that's what was causing the | ||
323 | // delivery to fail | ||
324 | if (!Pack.Header.Resent) | ||
325 | { | ||
326 | // Append any ACKs that need to be sent out to this packet | ||
327 | lock (PendingAcks) | ||
328 | { | ||
329 | if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS && | ||
330 | Pack.Type != PacketType.PacketAck && | ||
331 | Pack.Type != PacketType.LogoutRequest) | ||
332 | { | ||
333 | Pack.Header.AckList = new uint[PendingAcks.Count]; | ||
334 | int i = 0; | ||
335 | |||
336 | foreach (uint ack in PendingAcks.Values) | ||
337 | { | ||
338 | Pack.Header.AckList[i] = ack; | ||
339 | i++; | ||
340 | } | ||
341 | |||
342 | PendingAcks.Clear(); | ||
343 | Pack.Header.AppendedAcks = true; | ||
344 | } | ||
345 | } | ||
346 | } | ||
347 | } | ||
348 | } | ||
349 | |||
350 | |||
351 | byte[] ZeroOutBuffer = new byte[4096]; | ||
352 | byte[] sendbuffer; | ||
353 | sendbuffer = Pack.ToBytes(); | ||
354 | |||
355 | try | ||
356 | { | ||
357 | if (Pack.Header.Zerocoded) | ||
358 | { | ||
359 | int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); | ||
360 | OpenSim_Main.Server.SendTo(ZeroOutBuffer, packetsize, SocketFlags.None, userEP); | ||
361 | } | ||
362 | else | ||
363 | { | ||
364 | OpenSim_Main.Server.SendTo(sendbuffer, sendbuffer.Length, SocketFlags.None, userEP); | ||
365 | } | ||
366 | } | ||
367 | catch (Exception) | ||
368 | { | ||
369 | OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); | ||
370 | ClientThread.Abort(); | ||
371 | } | ||
372 | |||
373 | } | ||
374 | |||
375 | public void InPacket(Packet NewPack) | ||
376 | { | ||
377 | // Handle appended ACKs | ||
378 | if (NewPack.Header.AppendedAcks) | ||
379 | { | ||
380 | lock (NeedAck) | ||
381 | { | ||
382 | foreach (uint ack in NewPack.Header.AckList) | ||
383 | { | ||
384 | OpenSim_Main.localcons.WriteLine("Got appended ack: " + ack); | ||
385 | NeedAck.Remove(ack); | ||
386 | } | ||
387 | } | ||
388 | } | ||
389 | |||
390 | // Handle PacketAck packets | ||
391 | if (NewPack.Type == PacketType.PacketAck) | ||
392 | { | ||
393 | PacketAckPacket ackPacket = (PacketAckPacket)NewPack; | ||
394 | |||
395 | lock (NeedAck) | ||
396 | { | ||
397 | foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) | ||
398 | { | ||
399 | NeedAck.Remove(block.ID); | ||
400 | } | ||
401 | } | ||
402 | } | ||
403 | else if ((NewPack.Type == PacketType.StartPingCheck)) | ||
404 | { | ||
405 | //reply to pingcheck | ||
406 | libsecondlife.Packets.StartPingCheckPacket startPing = (libsecondlife.Packets.StartPingCheckPacket)NewPack; | ||
407 | libsecondlife.Packets.CompletePingCheckPacket endPing = new CompletePingCheckPacket(); | ||
408 | endPing.PingID.PingID = startPing.PingID.PingID; | ||
409 | OutPacket(endPing); | ||
410 | } | ||
411 | else | ||
412 | { | ||
413 | QueItem item = new QueItem(); | ||
414 | item.Packet = NewPack; | ||
415 | item.Incoming = true; | ||
416 | this.PacketQueue.Enqueue(item); | ||
417 | } | ||
418 | |||
419 | } | ||
420 | |||
421 | public void OutPacket(Packet NewPack) | ||
422 | { | ||
423 | QueItem item = new QueItem(); | ||
424 | item.Packet = NewPack; | ||
425 | item.Incoming = false; | ||
426 | this.PacketQueue.Enqueue(item); | ||
427 | } | ||
428 | |||
429 | public OpenSimClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack) | ||
430 | { | ||
431 | OpenSim_Main.localcons.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request"); | ||
432 | cirpack = initialcirpack; | ||
433 | userEP = remoteEP; | ||
434 | PacketQueue = new BlockingQueue<QueItem>(); | ||
435 | AssetRequests = new BlockingQueue<TransferRequestPacket>(); | ||
436 | AckTimer = new System.Timers.Timer(500); | ||
437 | AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); | ||
438 | AckTimer.Start(); | ||
439 | |||
440 | ClientThread = new Thread(new ThreadStart(AuthUser)); | ||
441 | ClientThread.IsBackground = true; | ||
442 | ClientThread.Start(); | ||
443 | } | ||
444 | |||
445 | private void ClientLoop() | ||
446 | { | ||
447 | OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:ClientLoop() - Entered loop"); | ||
448 | while (true) | ||
449 | { | ||
450 | QueItem nextPacket = PacketQueue.Dequeue(); | ||
451 | if (nextPacket.Incoming) | ||
452 | { | ||
453 | //is a incoming packet | ||
454 | ProcessInPacket(nextPacket.Packet); | ||
455 | } | ||
456 | else | ||
457 | { | ||
458 | //is a out going packet | ||
459 | ProcessOutPacket(nextPacket.Packet); | ||
460 | } | ||
461 | } | ||
462 | } | ||
463 | |||
464 | private void InitNewClient() | ||
465 | { | ||
466 | OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); | ||
467 | OpenSim_Main.local_world.AddViewerAgent(this); | ||
468 | world.Entity tempent = OpenSim_Main.local_world.Entities[this.AgentID]; | ||
469 | this.ClientAvatar = (world.Avatar)tempent; | ||
470 | } | ||
471 | |||
472 | private void AuthUser() | ||
473 | { | ||
474 | if (OpenSim_Main.cfg.sandbox == false) | ||
475 | { | ||
476 | OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AuthUser() - Authenticating new user request with grid"); | ||
477 | WebRequest CheckSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + cirpack.CircuitCode.ID.ToString() + "/" + cirpack.CircuitCode.Code.ToString() + "/exists"); | ||
478 | OpenSim_Main.localcons.WriteLine(OpenSim_Main.cfg.GridURL); | ||
479 | WebResponse GridResponse = CheckSession.GetResponse(); | ||
480 | StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); | ||
481 | String grTest = sr.ReadLine(); | ||
482 | sr.Close(); | ||
483 | GridResponse.Close(); | ||
484 | if (String.IsNullOrEmpty(grTest) || grTest.Equals("1")) | ||
485 | { // YAY! Valid login | ||
486 | OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString()); | ||
487 | this.AgentID = cirpack.CircuitCode.ID; | ||
488 | this.SessionID = cirpack.CircuitCode.SessionID; | ||
489 | this.CircuitCode = cirpack.CircuitCode.Code; | ||
490 | InitNewClient(); | ||
491 | ClientLoop(); | ||
492 | } | ||
493 | else | ||
494 | { // Invalid | ||
495 | OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString()); | ||
496 | ClientThread.Abort(); | ||
497 | } | ||
498 | } | ||
499 | else | ||
500 | { | ||
501 | this.AgentID = cirpack.CircuitCode.ID; | ||
502 | this.SessionID = cirpack.CircuitCode.SessionID; | ||
503 | this.CircuitCode = cirpack.CircuitCode.Code; | ||
504 | InitNewClient(); | ||
505 | ClientLoop(); | ||
506 | } | ||
507 | } | ||
508 | } | ||
509 | |||
510 | } | ||
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 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <OutputType>Exe</OutputType> | ||
4 | <RootNamespace>OpenSim</RootNamespace> | ||
5 | <AssemblyName>OpenSim</AssemblyName> | ||
6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
7 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
8 | <ProjectGuid>{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}</ProjectGuid> | ||
9 | <StartupObject>OpenSim.OpenSim_Main</StartupObject> | ||
10 | </PropertyGroup> | ||
11 | <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
12 | <OutputPath>..\bin\</OutputPath> | ||
13 | <Optimize>False</Optimize> | ||
14 | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
15 | <DebugSymbols>True</DebugSymbols> | ||
16 | <DebugType>Full</DebugType> | ||
17 | <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> | ||
18 | </PropertyGroup> | ||
19 | <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
20 | <OutputPath>..\bin\</OutputPath> | ||
21 | <Optimize>True</Optimize> | ||
22 | <DefineConstants>TRACE</DefineConstants> | ||
23 | <DebugSymbols>False</DebugSymbols> | ||
24 | <DebugType>None</DebugType> | ||
25 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
26 | </PropertyGroup> | ||
27 | <ItemGroup> | ||
28 | <Reference Include="Axiom.MathLib, Version=0.7.0.25497, Culture=neutral"> | ||
29 | <SpecificVersion>False</SpecificVersion> | ||
30 | <HintPath>..\bin\Axiom.MathLib.dll</HintPath> | ||
31 | </Reference> | ||
32 | <Reference Include="Db4objects.Db4o, Version=6.0.1.0, Culture=neutral, PublicKeyToken=6199cd4f203aa8eb, processorArchitecture=MSIL" /> | ||
33 | <Reference Include="libsecondlife, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
34 | <SpecificVersion>False</SpecificVersion> | ||
35 | <HintPath>..\bin\libsecondlife.dll</HintPath> | ||
36 | </Reference> | ||
37 | <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL"> | ||
38 | <SpecificVersion>False</SpecificVersion> | ||
39 | <HintPath>..\bin\log4net.dll</HintPath> | ||
40 | </Reference> | ||
41 | <Reference Include="System" /> | ||
42 | <Reference Include="System.Data" /> | ||
43 | <Reference Include="System.Xml" /> | ||
44 | </ItemGroup> | ||
45 | <ItemGroup> | ||
46 | <Compile Include="Config.cs" /> | ||
47 | <Compile Include="Main.cs" /> | ||
48 | <Compile Include="OpenSimClient.cs" /> | ||
49 | <Compile Include="ServerConsole.cs" /> | ||
50 | <Compile Include="types\Mesh.cs" /> | ||
51 | <Compile Include="types\Triangle.cs" /> | ||
52 | <Compile Include="Util.cs" /> | ||
53 | <Compile Include="VersionInfo.cs" /> | ||
54 | <Compile Include="world\Avatar.cs" /> | ||
55 | <Compile Include="world\Entity.cs" /> | ||
56 | <Compile Include="world\HeightmapGenHills.cs" /> | ||
57 | <Compile Include="world\PhysicsEngine.cs" /> | ||
58 | <Compile Include="world\Primitive.cs" /> | ||
59 | <Compile Include="world\ScriptEngine.cs" /> | ||
60 | <Compile Include="world\scripting\IScript.cs" /> | ||
61 | <Compile Include="world\SurfacePatch.cs" /> | ||
62 | <Compile Include="world\World.cs" /> | ||
63 | </ItemGroup> | ||
64 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | ||
65 | </Project> \ 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 @@ | |||
1 |  | ||
2 | Microsoft Visual Studio Solution File, Format Version 9.00 | ||
3 | # Visual Studio 2005 | ||
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Second-server", "Second-server.csproj", "{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}" | ||
5 | EndProject | ||
6 | Global | ||
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
8 | Debug|.NET 1.1 = Debug|.NET 1.1 | ||
9 | Debug|Any CPU = Debug|Any CPU | ||
10 | Release|.NET 1.1 = Release|.NET 1.1 | ||
11 | Release|Any CPU = Release|Any CPU | ||
12 | EndGlobalSection | ||
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
14 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|.NET 1.1.ActiveCfg = Debug|Any CPU | ||
15 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|.NET 1.1.Build.0 = Debug|Any CPU | ||
16 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
17 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
18 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|.NET 1.1.ActiveCfg = Release|Any CPU | ||
19 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 | ||
20 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
21 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
22 | EndGlobalSection | ||
23 | GlobalSection(SolutionProperties) = preSolution | ||
24 | HideSolutionNode = FALSE | ||
25 | EndGlobalSection | ||
26 | 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 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://osgrid.org/ | ||
3 | |||
4 | * Copyright (c) <year>, <copyright holder> | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions are met: | ||
9 | * * Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * * Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * * Neither the name of the <organization> nor the | ||
15 | * names of its contributors may be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
19 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
21 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | using System; | ||
31 | using System.Collections; | ||
32 | using System.Collections.Generic; | ||
33 | using System.Threading; | ||
34 | using System.IO; | ||
35 | using System.Net; | ||
36 | using libsecondlife; | ||
37 | using libsecondlife.Packets; | ||
38 | |||
39 | namespace OpenSim | ||
40 | { | ||
41 | public class ServerConsole { | ||
42 | private ConsoleType ConsType; | ||
43 | StreamWriter Log; | ||
44 | |||
45 | public enum ConsoleType { | ||
46 | Local, // Use stdio | ||
47 | TCP, // Use TCP/telnet | ||
48 | SimChat // Use in-world chat (for gods) | ||
49 | } | ||
50 | |||
51 | |||
52 | // STUPID HACK ALERT!!!! STUPID HACK ALERT!!!!! | ||
53 | // constype - the type of console to use (see enum ConsoleType) | ||
54 | // sparam - depending on the console type: | ||
55 | // TCP - the IP to bind to (127.0.0.1 if blank) | ||
56 | // Local - param ignored | ||
57 | // SimChat - the AgentID of this sim's admin | ||
58 | // and for the iparam: | ||
59 | // TCP - the port to bind to | ||
60 | // Local - param ignored | ||
61 | // SimChat - the chat channel to accept commands from | ||
62 | public ServerConsole(ConsoleType constype, string sparam, int iparam) { | ||
63 | ConsType = constype; | ||
64 | switch(constype) { | ||
65 | case ConsoleType.Local: | ||
66 | Console.WriteLine("ServerConsole.cs - creating new local console"); | ||
67 | Console.WriteLine("Logs will be saved to current directory in opensim-console.log"); | ||
68 | Log=File.AppendText("opensim-console.log"); | ||
69 | Log.WriteLine("========================================================================"); | ||
70 | Log.WriteLine("OpenSim " + VersionInfo.Version + " Started at " + DateTime.Now.ToString()); | ||
71 | break; | ||
72 | case ConsoleType.TCP: | ||
73 | break; | ||
74 | case ConsoleType.SimChat: | ||
75 | break; | ||
76 | |||
77 | default: | ||
78 | Console.WriteLine("ServerConsole.cs - what are you smoking? that isn't a valid console type!"); | ||
79 | break; | ||
80 | } | ||
81 | } | ||
82 | |||
83 | public void Close() { | ||
84 | Log.WriteLine("OpenSim shutdown at " + DateTime.Now.ToString()); | ||
85 | Log.Close(); | ||
86 | } | ||
87 | |||
88 | // 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 | ||
89 | public void WriteLine(string Line) { | ||
90 | Log.WriteLine(Line); | ||
91 | Console.WriteLine(Line); | ||
92 | return; | ||
93 | } | ||
94 | |||
95 | public string ReadLine() { | ||
96 | string TempStr=Console.ReadLine(); | ||
97 | Log.WriteLine(TempStr); | ||
98 | return TempStr; | ||
99 | } | ||
100 | |||
101 | public int Read() { | ||
102 | int TempInt= Console.Read(); | ||
103 | Log.Write((char)TempInt); | ||
104 | return TempInt; | ||
105 | } | ||
106 | |||
107 | public void Write(string Line) { | ||
108 | Console.Write(Line); | ||
109 | Log.Write(Line); | ||
110 | return; | ||
111 | } | ||
112 | |||
113 | // Displays a command prompt and waits for the user to enter a string, then returns that string | ||
114 | public string CmdPrompt(string prompt) { | ||
115 | this.Write(prompt); | ||
116 | return this.ReadLine(); | ||
117 | } | ||
118 | |||
119 | // Displays a command prompt and returns a default value if the user simply presses enter | ||
120 | public string CmdPrompt(string prompt, string defaultresponse) { | ||
121 | string temp=CmdPrompt(prompt); | ||
122 | if(temp=="") { | ||
123 | return defaultresponse; | ||
124 | } else { | ||
125 | return temp; | ||
126 | } | ||
127 | } | ||
128 | |||
129 | // Displays a command prompt and returns a default value, user may only enter 1 of 2 options | ||
130 | public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) { | ||
131 | bool itisdone=false; | ||
132 | string temp=CmdPrompt(prompt,defaultresponse); | ||
133 | while(itisdone==false) { | ||
134 | if((temp==OptionA) || (temp==OptionB)) { | ||
135 | itisdone=true; | ||
136 | } else { | ||
137 | this.WriteLine("Valid options are " + OptionA + " or " + OptionB); | ||
138 | temp=CmdPrompt(prompt,defaultresponse); | ||
139 | } | ||
140 | } | ||
141 | return temp; | ||
142 | } | ||
143 | |||
144 | // Runs a command with a number of parameters | ||
145 | public Object RunCmd(string Cmd, string[] cmdparams) { | ||
146 | switch(Cmd) { | ||
147 | case "help": | ||
148 | this.WriteLine("show users - show info about connected users"); | ||
149 | this.WriteLine("shutdown - disconnect all clients and shutdown"); | ||
150 | break; | ||
151 | |||
152 | case "show": | ||
153 | ShowCommands(cmdparams[0]); | ||
154 | break; | ||
155 | |||
156 | case "shutdown": | ||
157 | OpenSim_Main.Shutdown(); | ||
158 | break; | ||
159 | } | ||
160 | return null; | ||
161 | } | ||
162 | |||
163 | // Shows data about something | ||
164 | public void ShowCommands(string ShowWhat) { | ||
165 | switch(ShowWhat) { | ||
166 | case "uptime": | ||
167 | this.WriteLine("OpenSim has been running since " + OpenSim_Main.startuptime.ToString()); | ||
168 | this.WriteLine("That is " + (DateTime.Now-OpenSim_Main.startuptime).ToString()); | ||
169 | break; | ||
170 | case "users": | ||
171 | OpenSim.world.Avatar TempAv; | ||
172 | this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}","Firstname", "Lastname","Agent ID", "Session ID", "Circuit", "IP")); | ||
173 | foreach (libsecondlife.LLUUID UUID in OpenSim_Main.local_world.Entities.Keys) { | ||
174 | TempAv=(OpenSim.world.Avatar)OpenSim_Main.local_world.Entities[UUID]; | ||
175 | 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())); | ||
176 | } | ||
177 | break; | ||
178 | } | ||
179 | } | ||
180 | |||
181 | // Displays a prompt to the user and then runs the command they entered | ||
182 | public void MainConsolePrompt() { | ||
183 | string[] tempstrarray; | ||
184 | string tempstr = this.CmdPrompt("OpenSim-" + OpenSim_Main.cfg.RegionHandle.ToString() + " # "); | ||
185 | tempstrarray = tempstr.Split(' '); | ||
186 | string cmd=tempstrarray[0]; | ||
187 | Array.Reverse(tempstrarray); | ||
188 | Array.Resize<string>(ref tempstrarray,tempstrarray.Length-1); | ||
189 | Array.Reverse(tempstrarray); | ||
190 | string[] cmdparams=(string[])tempstrarray; | ||
191 | RunCmd(cmd,cmdparams); | ||
192 | } | ||
193 | } | ||
194 | |||
195 | } | ||
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 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://osgrid.org/ | ||
3 | |||
4 | * Copyright (c) <year>, <copyright holder> | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions are met: | ||
9 | * * Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * * Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * * Neither the name of the <organization> nor the | ||
15 | * names of its contributors may be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
19 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
21 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | using System; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Threading; | ||
33 | using libsecondlife; | ||
34 | using libsecondlife.Packets; | ||
35 | |||
36 | namespace OpenSim | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// </summary> | ||
40 | public class QueItem { | ||
41 | public QueItem() | ||
42 | { | ||
43 | } | ||
44 | |||
45 | public Packet Packet; | ||
46 | public bool Incoming; | ||
47 | } | ||
48 | |||
49 | |||
50 | public class BlockingQueue< T > { | ||
51 | private Queue< T > _queue = new Queue< T >(); | ||
52 | private object _queueSync = new object(); | ||
53 | |||
54 | public void Enqueue(T value) | ||
55 | { | ||
56 | lock(_queueSync) | ||
57 | { | ||
58 | _queue.Enqueue(value); | ||
59 | Monitor.Pulse(_queueSync); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | public T Dequeue() | ||
64 | { | ||
65 | lock(_queueSync) | ||
66 | { | ||
67 | if( _queue.Count < 1) | ||
68 | Monitor.Wait(_queueSync); | ||
69 | |||
70 | return _queue.Dequeue(); | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | |||
75 | } | ||
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 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://osgrid.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | using System; | ||
28 | |||
29 | namespace OpenSim | ||
30 | { | ||
31 | /// <summary> | ||
32 | /// </summary> | ||
33 | public class VersionInfo | ||
34 | { | ||
35 | public static string Version = "0.0.1-unofficial"; | ||
36 | } | ||
37 | } | ||
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 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://osgrid.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | */ | ||
26 | |||
27 | using System; | ||
28 | |||
29 | namespace OpenSim | ||
30 | { | ||
31 | /// <summary> | ||
32 | /// </summary> | ||
33 | public class VersionInfo | ||
34 | { | ||
35 | public static string Version = "@@VERSION"; | ||
36 | } | ||
37 | } | ||
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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.types | ||
6 | { | ||
7 | // TODO: This will need some performance tuning no doubt. | ||
8 | public class Mesh | ||
9 | { | ||
10 | public List<Triangle> mesh; | ||
11 | |||
12 | public Mesh() | ||
13 | { | ||
14 | mesh = new List<Triangle>(); | ||
15 | } | ||
16 | |||
17 | public void AddTri(Triangle tri) | ||
18 | { | ||
19 | mesh.Add(tri); | ||
20 | } | ||
21 | |||
22 | public static Mesh operator +(Mesh a, Mesh b) | ||
23 | { | ||
24 | a.mesh.AddRange(b.mesh); | ||
25 | return a; | ||
26 | } | ||
27 | } | ||
28 | } | ||
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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using Axiom.MathLib; | ||
5 | |||
6 | namespace OpenSim.types | ||
7 | { | ||
8 | public class Triangle | ||
9 | { | ||
10 | Vector3 a; | ||
11 | Vector3 b; | ||
12 | Vector3 c; | ||
13 | |||
14 | public Triangle() | ||
15 | { | ||
16 | a = new Vector3(); | ||
17 | b = new Vector3(); | ||
18 | c = new Vector3(); | ||
19 | } | ||
20 | |||
21 | public Triangle(Vector3 A, Vector3 B, Vector3 C) | ||
22 | { | ||
23 | a = A; | ||
24 | b = B; | ||
25 | c = C; | ||
26 | } | ||
27 | } | ||
28 | } | ||
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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.IO; | ||
4 | using System.Text; | ||
5 | using libsecondlife; | ||
6 | using libsecondlife.Packets; | ||
7 | using Axiom.MathLib; | ||
8 | |||
9 | namespace OpenSim.world | ||
10 | { | ||
11 | public class Avatar : Entity | ||
12 | { | ||
13 | public string firstname; | ||
14 | public string lastname; | ||
15 | public OpenSimClient ControllingClient; | ||
16 | public LLVector3 oldvel; | ||
17 | public LLVector3 oldpos; | ||
18 | public uint CurrentKeyMask; | ||
19 | public bool walking; | ||
20 | |||
21 | private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; | ||
22 | |||
23 | public Avatar(OpenSimClient TheClient) { | ||
24 | OpenSim_Main.localcons.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); | ||
25 | ControllingClient=TheClient; | ||
26 | SetupTemplate("avatar-template.dat"); | ||
27 | |||
28 | position = new LLVector3(100.0f,100.0f,60.0f); | ||
29 | } | ||
30 | |||
31 | public override void update() { | ||
32 | lock(this) { | ||
33 | base.update(); | ||
34 | |||
35 | oldvel=this.velocity; | ||
36 | oldpos=this.position; | ||
37 | if((this.CurrentKeyMask & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) != 0) { | ||
38 | Vector3 tmpVelocity = this.rotation * new Vector3(1.0f,0.0f,0.0f); | ||
39 | tmpVelocity.Normalize(); tmpVelocity = tmpVelocity * 0.5f; | ||
40 | this.velocity.X = tmpVelocity.x; | ||
41 | this.velocity.Y = tmpVelocity.y; | ||
42 | this.velocity.Z = tmpVelocity.z; | ||
43 | this.walking=true; | ||
44 | } else { | ||
45 | this.velocity.X=0; | ||
46 | this.velocity.Y=0; | ||
47 | this.velocity.Z=0; | ||
48 | this.walking=false; | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | |||
53 | private void SetupTemplate(string name) | ||
54 | { | ||
55 | |||
56 | int i = 0; | ||
57 | FileInfo fInfo = new FileInfo(name); | ||
58 | long numBytes = fInfo.Length; | ||
59 | FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); | ||
60 | BinaryReader br = new BinaryReader(fStream); | ||
61 | byte [] data1 = br.ReadBytes((int)numBytes); | ||
62 | br.Close(); | ||
63 | fStream.Close(); | ||
64 | |||
65 | libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); | ||
66 | |||
67 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
68 | libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16); | ||
69 | pos.X = 100f; | ||
70 | objdata.ID = this.localid; | ||
71 | objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); | ||
72 | libsecondlife.LLVector3 pos2 = new LLVector3(100f,100f,23f); | ||
73 | //objdata.FullID=user.AgentID; | ||
74 | byte[] pb = pos.GetBytes(); | ||
75 | Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); | ||
76 | |||
77 | AvatarTemplate = objdata; | ||
78 | |||
79 | } | ||
80 | |||
81 | public void CompleteMovement(World RegionInfo) { | ||
82 | OpenSim_Main.localcons.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet"); | ||
83 | AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); | ||
84 | mov.AgentData.SessionID = this.ControllingClient.SessionID; | ||
85 | mov.AgentData.AgentID = this.ControllingClient.AgentID; | ||
86 | mov.Data.RegionHandle = OpenSim_Main.cfg.RegionHandle; | ||
87 | // TODO - dynamicalise this stuff | ||
88 | mov.Data.Timestamp = 1172750370; | ||
89 | mov.Data.Position = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z); | ||
90 | mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0); | ||
91 | |||
92 | OpenSim_Main.localcons.WriteLine("Sending AgentMovementComplete packet"); | ||
93 | ControllingClient.OutPacket(mov); | ||
94 | } | ||
95 | |||
96 | public void SendInitialPosition() { | ||
97 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
98 | |||
99 | |||
100 | //send a objectupdate packet with information about the clients avatar | ||
101 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
102 | objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; | ||
103 | objupdate.RegionData.TimeDilation = 64096; | ||
104 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
105 | |||
106 | objupdate.ObjectData[0] = AvatarTemplate; | ||
107 | //give this avatar object a local id and assign the user a name | ||
108 | objupdate.ObjectData[0].ID = this.localid; | ||
109 | //User_info.name="Test"+this.local_numer+" User"; | ||
110 | objupdate.ObjectData[0].FullID = ControllingClient.AgentID; | ||
111 | objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); | ||
112 | |||
113 | libsecondlife.LLVector3 pos2 = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z); | ||
114 | |||
115 | byte[] pb = pos2.GetBytes(); | ||
116 | |||
117 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); | ||
118 | OpenSim_Main.local_world._localNumber++; | ||
119 | this.ControllingClient.OutPacket(objupdate); | ||
120 | } | ||
121 | |||
122 | public override ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() { | ||
123 | byte[] bytes = new byte[60]; | ||
124 | int i=0; | ||
125 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | ||
126 | |||
127 | dat.TextureEntry = AvatarTemplate.TextureEntry; | ||
128 | libsecondlife.LLVector3 pos2 = new LLVector3(this.position.X, this.position.Y, this.position.Z); | ||
129 | |||
130 | uint ID = this.localid; | ||
131 | bytes[i++] = (byte)(ID % 256); | ||
132 | bytes[i++] = (byte)((ID >> 8) % 256); | ||
133 | bytes[i++] = (byte)((ID >> 16) % 256); | ||
134 | bytes[i++] = (byte)((ID >> 24) % 256); | ||
135 | bytes[i++] = 0; | ||
136 | bytes[i++] = 1; | ||
137 | i += 14; | ||
138 | bytes[i++] = 128; | ||
139 | bytes[i++] = 63; | ||
140 | |||
141 | byte[] pb = pos2.GetBytes(); | ||
142 | Array.Copy(pb, 0, bytes, i, pb.Length); | ||
143 | i += 12; | ||
144 | |||
145 | |||
146 | ushort ac = 32767; | ||
147 | bytes[i++] = (byte)((ushort)(((this.velocity.X/128f)+1)*32767) % 256 ); | ||
148 | bytes[i++] = (byte)(((ushort)(((this.velocity.X/128f)+1)*32767) >> 8) % 256); | ||
149 | bytes[i++] = (byte)((ushort)(((this.velocity.Y/128f)+1)*32767) % 256); | ||
150 | bytes[i++] = (byte)(((ushort)(((this.velocity.Y/128f)+1)*32767) >> 8) % 256); | ||
151 | bytes[i++] = (byte)((ushort)(((this.velocity.Z/128f)+1)*32767) % 256); | ||
152 | bytes[i++] = (byte)(((ushort)(((this.velocity.Z/128f)+1)*32767) >> 8) % 256); | ||
153 | |||
154 | |||
155 | |||
156 | |||
157 | //accel | ||
158 | bytes[i++] = (byte)(ac % 256); | ||
159 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
160 | bytes[i++] = (byte)(ac % 256); | ||
161 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
162 | bytes[i++] = (byte)(ac % 256); | ||
163 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
164 | |||
165 | //rot | ||
166 | bytes[i++] = (byte)(ac % 256); | ||
167 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
168 | bytes[i++] = (byte)(ac % 256); | ||
169 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
170 | bytes[i++] = (byte)(ac % 256); | ||
171 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
172 | bytes[i++] = (byte)(ac % 256); | ||
173 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
174 | |||
175 | //rotation vel | ||
176 | bytes[i++] = (byte)(ac % 256); | ||
177 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
178 | bytes[i++] = (byte)(ac % 256); | ||
179 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
180 | bytes[i++] = (byte)(ac % 256); | ||
181 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
182 | |||
183 | dat.Data=bytes; | ||
184 | return(dat); | ||
185 | |||
186 | } | ||
187 | |||
188 | public void SendInitialAppearance() { | ||
189 | AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); | ||
190 | aw.AgentData.AgentID = this.ControllingClient.AgentID; | ||
191 | aw.AgentData.SerialNum = 0; | ||
192 | aw.AgentData.SessionID = ControllingClient.SessionID; | ||
193 | |||
194 | aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; | ||
195 | AgentWearablesUpdatePacket.WearableDataBlock awb = new AgentWearablesUpdatePacket.WearableDataBlock(); | ||
196 | awb.WearableType = (byte)0; | ||
197 | awb.AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); | ||
198 | awb.ItemID = LLUUID.Random(); | ||
199 | aw.WearableData[0] = awb; | ||
200 | |||
201 | for(int i=1; i<13; i++) { | ||
202 | awb = new AgentWearablesUpdatePacket.WearableDataBlock(); | ||
203 | awb.WearableType = (byte)i; | ||
204 | awb.AssetID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
205 | awb.ItemID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
206 | aw.WearableData[i] = awb; | ||
207 | } | ||
208 | |||
209 | ControllingClient.OutPacket(aw); | ||
210 | } | ||
211 | |||
212 | public void SendRegionHandshake(World RegionInfo) { | ||
213 | OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet"); | ||
214 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
215 | RegionHandshakePacket handshake = new RegionHandshakePacket(); | ||
216 | |||
217 | OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details"); | ||
218 | handshake.RegionInfo.BillableFactor = 0; | ||
219 | handshake.RegionInfo.IsEstateManager = false; | ||
220 | handshake.RegionInfo.TerrainHeightRange00 = 60; | ||
221 | handshake.RegionInfo.TerrainHeightRange01 = 60; | ||
222 | handshake.RegionInfo.TerrainHeightRange10 = 60; | ||
223 | handshake.RegionInfo.TerrainHeightRange11 = 60; | ||
224 | handshake.RegionInfo.TerrainStartHeight00 = 10; | ||
225 | handshake.RegionInfo.TerrainStartHeight01 = 10; | ||
226 | handshake.RegionInfo.TerrainStartHeight10 = 10; | ||
227 | handshake.RegionInfo.TerrainStartHeight11 = 10; | ||
228 | handshake.RegionInfo.SimAccess = 13; | ||
229 | handshake.RegionInfo.WaterHeight = 20.0f; | ||
230 | handshake.RegionInfo.RegionFlags = 72458694; // TODO: WTF sirs? Use an enum! | ||
231 | handshake.RegionInfo.SimName = _enc.GetBytes(OpenSim_Main.cfg.RegionName + "\0"); | ||
232 | handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
233 | handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); | ||
234 | handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); | ||
235 | handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); | ||
236 | handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); | ||
237 | handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
238 | handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
239 | handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
240 | handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
241 | handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37"); | ||
242 | |||
243 | OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet"); | ||
244 | this.ControllingClient.OutPacket(handshake); | ||
245 | } | ||
246 | |||
247 | public void HandleAgentUpdate(AgentUpdatePacket update) { | ||
248 | lock(this) { | ||
249 | this.CurrentKeyMask = update.AgentData.ControlFlags; | ||
250 | this.rotation = new Quaternion(update.AgentData.BodyRotation.W, update.AgentData.BodyRotation.X, update.AgentData.BodyRotation.Y, update.AgentData.BodyRotation.Z); | ||
251 | this.needupdate = true; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | } | ||
256 | } | ||
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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using Axiom.MathLib; | ||
5 | using libsecondlife; | ||
6 | using OpenSim.types; | ||
7 | using libsecondlife.Packets; | ||
8 | |||
9 | namespace OpenSim.world | ||
10 | { | ||
11 | public class Entity | ||
12 | { | ||
13 | protected libsecondlife.LLUUID uuid; | ||
14 | protected uint localid; | ||
15 | public LLVector3 position; | ||
16 | public LLVector3 velocity; | ||
17 | protected Quaternion rotation; | ||
18 | protected string name; | ||
19 | protected List<Entity> children; | ||
20 | public bool needupdate; | ||
21 | |||
22 | public Entity() | ||
23 | { | ||
24 | uuid = new libsecondlife.LLUUID(); | ||
25 | localid = 8880000 + (OpenSim_Main.local_world._localNumber++); // FIXME - race condition! | ||
26 | position = new LLVector3(); | ||
27 | velocity = new LLVector3(); | ||
28 | rotation = new Quaternion(); | ||
29 | name = "(basic entity)"; | ||
30 | children = new List<Entity>(); | ||
31 | } | ||
32 | |||
33 | public virtual void update() { | ||
34 | // Do any per-frame updates needed that are applicable to every type of entity | ||
35 | foreach (Entity child in children) | ||
36 | { | ||
37 | if(child.needupdate) | ||
38 | child.update(); | ||
39 | } | ||
40 | this.needupdate=false; | ||
41 | } | ||
42 | |||
43 | public virtual ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() { | ||
44 | return null; | ||
45 | } | ||
46 | |||
47 | |||
48 | public virtual string getName() | ||
49 | { | ||
50 | return name; | ||
51 | } | ||
52 | |||
53 | public virtual Mesh getMesh() | ||
54 | { | ||
55 | Mesh mesh = new Mesh(); | ||
56 | |||
57 | foreach (Entity child in children) | ||
58 | { | ||
59 | mesh += child.getMesh(); | ||
60 | } | ||
61 | |||
62 | return mesh; | ||
63 | } | ||
64 | } | ||
65 | } | ||
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 @@ | |||
1 | using System; | ||
2 | |||
3 | namespace libsecondlife | ||
4 | { | ||
5 | public class HeightmapGenHills | ||
6 | { | ||
7 | private Random Rand = new Random(); | ||
8 | private int NumHills; | ||
9 | private float HillMin; | ||
10 | private float HillMax; | ||
11 | private bool Island; | ||
12 | private float[] heightmap; | ||
13 | |||
14 | public float[] GenerateHeightmap(int numHills, float hillMin, float hillMax, bool island) | ||
15 | { | ||
16 | NumHills = numHills; | ||
17 | HillMin = hillMin; | ||
18 | HillMax = hillMax; | ||
19 | Island = island; | ||
20 | |||
21 | heightmap = new float[256 * 256]; | ||
22 | |||
23 | for (int i = 0; i < numHills; i++) | ||
24 | { | ||
25 | AddHill(); | ||
26 | } | ||
27 | |||
28 | Normalize(); | ||
29 | |||
30 | return heightmap; | ||
31 | } | ||
32 | |||
33 | private void AddHill() | ||
34 | { | ||
35 | float x, y; | ||
36 | float radius = RandomRange(HillMin, HillMax); | ||
37 | |||
38 | if (Island) | ||
39 | { | ||
40 | // Which direction from the center of the map the hill is placed | ||
41 | float theta = RandomRange(0, 6.28f); | ||
42 | |||
43 | // How far from the center of the map to place the hill. The radius | ||
44 | // is subtracted from the range to prevent any part of the hill from | ||
45 | // reaching the edge of the map | ||
46 | float distance = RandomRange(radius / 2.0f, 128.0f - radius); | ||
47 | |||
48 | x = 128.0f + (float)Math.Cos(theta) * distance; | ||
49 | y = 128.0f + (float)Math.Sin(theta) * distance; | ||
50 | } | ||
51 | else | ||
52 | { | ||
53 | x = RandomRange(-radius, 256.0f + radius); | ||
54 | y = RandomRange(-radius, 256.0f + radius); | ||
55 | } | ||
56 | |||
57 | float radiusSq = radius * radius; | ||
58 | float distSq; | ||
59 | float height; | ||
60 | |||
61 | int xMin = (int)(x - radius) - 1; | ||
62 | int xMax = (int)(x + radius) + 1; | ||
63 | if (xMin < 0) xMin = 0; | ||
64 | if (xMax > 255) xMax = 255; | ||
65 | |||
66 | int yMin = (int)(y - radius) - 1; | ||
67 | int yMax = (int)(y + radius) + 1; | ||
68 | if (yMin < 0) yMin = 0; | ||
69 | if (yMax > 255) yMax = 255; | ||
70 | |||
71 | // Loop through each affected cell and determine the height at that point | ||
72 | for (int v = yMin; v <= yMax; ++v) | ||
73 | { | ||
74 | float fv = (float)v; | ||
75 | |||
76 | for (int h = xMin; h <= xMax; ++h) | ||
77 | { | ||
78 | float fh = (float)h; | ||
79 | |||
80 | // Determine how far from the center of this hill this point is | ||
81 | distSq = (x - fh) * (x - fh) + (y - fv) * (y - fv); | ||
82 | height = radiusSq - distSq; | ||
83 | |||
84 | // Don't add negative hill values | ||
85 | if (height > 0.0f) heightmap[h + v * 256] += height; | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | |||
90 | private void Normalize() | ||
91 | { | ||
92 | float min = heightmap[0]; | ||
93 | float max = heightmap[0]; | ||
94 | |||
95 | for (int x = 0; x < 256; x++) | ||
96 | { | ||
97 | for (int y = 0; y < 256; y++) | ||
98 | { | ||
99 | if (heightmap[x + y * 256] < min) min = heightmap[x + y * 256]; | ||
100 | if (heightmap[x + y * 256] > max) max = heightmap[x + y * 256]; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | // Avoid a rare divide by zero | ||
105 | if (min != max) | ||
106 | { | ||
107 | for (int x = 0; x < 256; x++) | ||
108 | { | ||
109 | for (int y = 0; y < 256; y++) | ||
110 | { | ||
111 | heightmap[x + y * 256] = ((heightmap[x + y * 256] - min) / (max - min)) * (HillMax - HillMin); | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | |||
117 | private float RandomRange(float min, float max) | ||
118 | { | ||
119 | return (float)Rand.NextDouble() * (max - min) + min; | ||
120 | } | ||
121 | } | ||
122 | } | ||
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 @@ | |||
1 | using System; | ||
2 | using System.Threading; | ||
3 | using libsecondlife; | ||
4 | using libsecondlife.Packets; | ||
5 | using System.Collections.Generic; | ||
6 | using System.Text; | ||
7 | |||
8 | namespace OpenSim.world | ||
9 | { | ||
10 | public class PhysicsEngine | ||
11 | { | ||
12 | |||
13 | public PhysicsEngine() { | ||
14 | } | ||
15 | |||
16 | public void Startup() { | ||
17 | OpenSim_Main.localcons.WriteLine("PhysicsEngine.cs:Startup() - DOING NOTHING, DUMMY FUNCTION!"); | ||
18 | } | ||
19 | |||
20 | public void DoStuff(World simworld) { | ||
21 | foreach (libsecondlife.LLUUID UUID in simworld.Entities.Keys) | ||
22 | { | ||
23 | simworld.Entities[UUID].position += simworld.Entities[UUID].velocity; | ||
24 | simworld.Entities[UUID].position.Z = simworld.LandMap[(int)simworld.Entities[UUID].position.Y * 256 + (int)simworld.Entities[UUID].position.X]+1; | ||
25 | if(simworld.Entities[UUID].position.X<0) simworld.Entities[UUID].position.X=0; | ||
26 | if(simworld.Entities[UUID].position.Y<0) simworld.Entities[UUID].position.Y=0; | ||
27 | if(simworld.Entities[UUID].position.X>255) simworld.Entities[UUID].position.X=255; | ||
28 | if(simworld.Entities[UUID].position.Y>255) simworld.Entities[UUID].position.Y=255; | ||
29 | } | ||
30 | } | ||
31 | } | ||
32 | } | ||
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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim.types; | ||
5 | |||
6 | namespace OpenSim.world | ||
7 | { | ||
8 | public class Primitive : Entity | ||
9 | { | ||
10 | protected float mesh_cutbegin; | ||
11 | protected float mesh_cutend; | ||
12 | |||
13 | public Primitive() | ||
14 | { | ||
15 | mesh_cutbegin = 0.0f; | ||
16 | mesh_cutend = 1.0f; | ||
17 | } | ||
18 | |||
19 | public override Mesh getMesh() | ||
20 | { | ||
21 | Mesh mesh = new Mesh(); | ||
22 | Triangle tri = new Triangle( | ||
23 | new Axiom.MathLib.Vector3(0.0f, 1.0f, 1.0f), | ||
24 | new Axiom.MathLib.Vector3(1.0f, 0.0f, 1.0f), | ||
25 | new Axiom.MathLib.Vector3(1.0f, 1.0f, 0.0f)); | ||
26 | |||
27 | mesh.AddTri(tri); | ||
28 | mesh += base.getMesh(); | ||
29 | |||
30 | return mesh; | ||
31 | } | ||
32 | } | ||
33 | } | ||
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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.world | ||
6 | { | ||
7 | public class ScriptEngine | ||
8 | { | ||
9 | public ScriptEngine(World env) | ||
10 | { | ||
11 | } | ||
12 | |||
13 | public void LoadScript() | ||
14 | { | ||
15 | |||
16 | } | ||
17 | } | ||
18 | } | ||
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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.world | ||
6 | { | ||
7 | public class SurfacePatch | ||
8 | { | ||
9 | public float[] HeightMap; | ||
10 | |||
11 | public SurfacePatch() { | ||
12 | HeightMap = new float[16*16]; | ||
13 | |||
14 | int xinc; | ||
15 | int yinc; | ||
16 | for(xinc=0; xinc<16; xinc++) for(yinc=0; yinc<16; yinc++) { | ||
17 | HeightMap[xinc+(yinc*16)]=100.0f; | ||
18 | } | ||
19 | |||
20 | } | ||
21 | } | ||
22 | } | ||
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 @@ | |||
1 | using System; | ||
2 | using System.Threading; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Text; | ||
5 | using libsecondlife; | ||
6 | using libsecondlife.Packets; | ||
7 | |||
8 | namespace OpenSim.world | ||
9 | { | ||
10 | public class World | ||
11 | { | ||
12 | public Dictionary<libsecondlife.LLUUID, Entity> Entities; | ||
13 | public float[] LandMap; | ||
14 | public ScriptEngine Scripts; | ||
15 | public uint _localNumber = 0; | ||
16 | public PhysicsEngine physics; | ||
17 | |||
18 | private libsecondlife.TerrainManager TerrainManager; | ||
19 | private Random Rand = new Random(); | ||
20 | |||
21 | public World() | ||
22 | { | ||
23 | OpenSim_Main.localcons.WriteLine("World.cs - creating new entitities instance"); | ||
24 | Entities = new Dictionary<libsecondlife.LLUUID, Entity>(); | ||
25 | |||
26 | OpenSim_Main.localcons.WriteLine("World.cs - creating LandMap"); | ||
27 | TerrainManager = new TerrainManager(new SecondLife()); | ||
28 | } | ||
29 | |||
30 | public void InitLoop() | ||
31 | { | ||
32 | OpenSim_Main.localcons.WriteLine("World.cs:StartLoop() - Initialising physics"); | ||
33 | this.physics = new PhysicsEngine(); | ||
34 | physics.Startup(); | ||
35 | } | ||
36 | |||
37 | public void DoStuff() | ||
38 | { | ||
39 | lock (this) | ||
40 | { | ||
41 | physics.DoStuff(this); | ||
42 | this.Update(); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | public void Update() | ||
47 | { | ||
48 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
49 | { | ||
50 | if (Entities[UUID].needupdate) | ||
51 | { | ||
52 | Entities[UUID].update(); | ||
53 | |||
54 | if (Entities[UUID] is Avatar) | ||
55 | { | ||
56 | Avatar avatar = (Avatar)Entities[UUID]; | ||
57 | if ((avatar.oldpos != avatar.position) || (avatar.oldvel != avatar.velocity) || avatar.walking) | ||
58 | { | ||
59 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = Entities[UUID].CreateTerseBlock(); | ||
60 | foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) | ||
61 | { | ||
62 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | ||
63 | terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME | ||
64 | terse.RegionData.TimeDilation = 0; | ||
65 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
66 | terse.ObjectData[0] = terseBlock; | ||
67 | client.OutPacket(terse); | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | |||
75 | public void SendLayerData(OpenSimClient RemoteClient) | ||
76 | { | ||
77 | int[] patches = new int[4]; | ||
78 | |||
79 | for (int y = 0; y < 16; y++) | ||
80 | { | ||
81 | for (int x = 0; x < 16; x = x + 4) | ||
82 | { | ||
83 | patches[0] = x + 0 + y * 16; | ||
84 | patches[1] = x + 1 + y * 16; | ||
85 | patches[2] = x + 2 + y * 16; | ||
86 | patches[3] = x + 3 + y * 16; | ||
87 | |||
88 | Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches); | ||
89 | RemoteClient.OutPacket(layerpack); | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | |||
94 | public void AddViewerAgent(OpenSimClient AgentClient) | ||
95 | { | ||
96 | OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); | ||
97 | Avatar NewAvatar = new Avatar(AgentClient); | ||
98 | OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); | ||
99 | this.Entities.Add(AgentClient.AgentID, NewAvatar); | ||
100 | OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); | ||
101 | NewAvatar.SendRegionHandshake(this); | ||
102 | this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user | ||
103 | } | ||
104 | |||
105 | public bool Backup() | ||
106 | { | ||
107 | /* TODO: Save the current world entities state. */ | ||
108 | |||
109 | return false; | ||
110 | } | ||
111 | } | ||
112 | } | ||
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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.world.scripting | ||
6 | { | ||
7 | public interface IScriptHost { | ||
8 | bool Register(IScript iscript); | ||
9 | } | ||
10 | public interface IScript | ||
11 | { | ||
12 | string Name{get;set;} | ||
13 | IScriptHost Host{get;set;} | ||
14 | void Show(); | ||
15 | } | ||
16 | } | ||