diff options
author | gareth | 2007-02-27 22:59:35 +0000 |
---|---|---|
committer | gareth | 2007-02-27 22:59:35 +0000 |
commit | 5453580d550e96cdeeec855d610082c662562022 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
parent | Patch Applied regarding Bug #51 (diff) | |
download | opensim-SC-5453580d550e96cdeeec855d610082c662562022.zip opensim-SC-5453580d550e96cdeeec855d610082c662562022.tar.gz opensim-SC-5453580d550e96cdeeec855d610082c662562022.tar.bz2 opensim-SC-5453580d550e96cdeeec855d610082c662562022.tar.xz |
Removed old trunk code
Diffstat (limited to '')
-rw-r--r-- | Agent_Manager.cs | 879 | ||||
-rw-r--r-- | AssemblyInfo.cs | 59 | ||||
-rw-r--r-- | AssetManagement.cs | 469 | ||||
-rw-r--r-- | Asset_manager.cs | 231 | ||||
-rw-r--r-- | Controller.cs | 358 | ||||
-rw-r--r-- | Globals.cs | 66 | ||||
-rw-r--r-- | GridManager.cs | 372 | ||||
-rw-r--r-- | InventoryManager.cs | 242 | ||||
-rw-r--r-- | Login_manager.cs | 228 | ||||
-rw-r--r-- | Physics_manager.cs | 41 | ||||
-rw-r--r-- | Prim_manager.cs | 382 | ||||
-rw-r--r-- | SceneGraphManager.cs | 40 | ||||
-rw-r--r-- | Script_manager.cs | 103 | ||||
-rw-r--r-- | Second-server.csproj | 61 | ||||
-rw-r--r-- | Second-server.sln | 34 | ||||
-rw-r--r-- | Server.cs | 645 | ||||
-rw-r--r-- | StorageManager.cs | 53 | ||||
-rw-r--r-- | Texture_manager.cs | 238 | ||||
-rw-r--r-- | bin/Release/(TwoRegion)Grid.ini | 7 | ||||
-rw-r--r-- | bin/Release/Grid.ini | 6 | ||||
-rw-r--r-- | bin/Release/new-login.dat | 2 | ||||
-rw-r--r-- | bin/Release/textures/map1.jp2 | bin | 570 -> 0 bytes | |||
-rw-r--r-- | bin/Release/textures/map_base.jp2 | bin | 153 -> 0 bytes | |||
-rw-r--r-- | lib/Axiom.MathLib.dll | bin | 69632 -> 0 bytes | |||
-rw-r--r-- | lib/log4net.dll | bin | 270336 -> 0 bytes |
25 files changed, 0 insertions, 4516 deletions
diff --git a/Agent_Manager.cs b/Agent_Manager.cs deleted file mode 100644 index 11b523e..0000000 --- a/Agent_Manager.cs +++ /dev/null | |||
@@ -1,879 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://sim.opensecondlife.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.Generic; | ||
29 | using libsecondlife; | ||
30 | using libsecondlife.Packets; | ||
31 | using libsecondlife.AssetSystem; | ||
32 | using System.IO; | ||
33 | using Axiom.MathLib; | ||
34 | |||
35 | namespace OpenSim | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Description of Agent_Manager. | ||
39 | /// </summary> | ||
40 | public class AgentManager | ||
41 | { | ||
42 | public Dictionary<libsecondlife.LLUUID,AvatarData> AgentList; | ||
43 | public static Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>(); | ||
44 | public static Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>(); | ||
45 | |||
46 | private uint _localNumber=0; | ||
47 | private Server _server; | ||
48 | public PrimManager Prim_Manager; | ||
49 | public AssetManagement assetManager; | ||
50 | |||
51 | private libsecondlife.Packets.RegionHandshakePacket RegionPacket; | ||
52 | private System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
53 | private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; | ||
54 | |||
55 | /// <summary> | ||
56 | /// | ||
57 | /// </summary> | ||
58 | /// <param name="serve"></param> | ||
59 | public AgentManager(Server server) | ||
60 | { | ||
61 | AgentList = new Dictionary<libsecondlife.LLUUID,AvatarData>(); | ||
62 | _server = server; | ||
63 | this.initialise(); | ||
64 | } | ||
65 | |||
66 | /// <summary> | ||
67 | /// | ||
68 | /// </summary> | ||
69 | /// <param name="id"></param> | ||
70 | /// <returns></returns> | ||
71 | public AvatarData GetAgent(LLUUID id) | ||
72 | { | ||
73 | if(!this.AgentList.ContainsKey(id)) | ||
74 | { | ||
75 | return null; | ||
76 | } | ||
77 | else | ||
78 | { | ||
79 | AvatarData avatar = this.AgentList[id]; | ||
80 | return avatar; | ||
81 | } | ||
82 | } | ||
83 | /// <summary> | ||
84 | /// | ||
85 | /// </summary> | ||
86 | /// <param name="agent"></param> | ||
87 | public void AddAgent(AvatarData agent) | ||
88 | { | ||
89 | this.AgentList.Add(agent.FullID, agent); | ||
90 | } | ||
91 | /// <summary> | ||
92 | /// | ||
93 | /// </summary> | ||
94 | /// <param name="User_info"></param> | ||
95 | /// <param name="first"></param> | ||
96 | /// <param name="last"></param> | ||
97 | /// <returns></returns> | ||
98 | /// | ||
99 | |||
100 | /// <summary> | ||
101 | /// | ||
102 | /// </summary> | ||
103 | /// <param name="User_info"></param> | ||
104 | /// <param name="first"></param> | ||
105 | /// <param name="last"></param> | ||
106 | /// <returns></returns> | ||
107 | public bool NewAgent(UserAgentInfo userInfo, string first, string last, LLUUID baseFolder, LLUUID inventoryFolder) | ||
108 | { | ||
109 | AvatarData agent = new AvatarData(); | ||
110 | agent.FullID = userInfo.AgentID; | ||
111 | agent.NetInfo = userInfo; | ||
112 | agent.NetInfo.first_name =first; | ||
113 | agent.NetInfo.last_name = last; | ||
114 | agent.Position = new LLVector3(100, 100, 22); | ||
115 | agent.BaseFolder = baseFolder; | ||
116 | agent.InventoryFolder = inventoryFolder; | ||
117 | agent.AnimID = AnimsLLUUID["ANIM_AGENT_STAND"]; | ||
118 | agent.AnimSequenceID = 1; | ||
119 | |||
120 | this.AgentList.Add(agent.FullID, agent); | ||
121 | |||
122 | //Create new Wearable Assets and place in Inventory | ||
123 | this.assetManager.CreateNewInventorySet(ref agent, userInfo); | ||
124 | |||
125 | return(true); | ||
126 | } | ||
127 | |||
128 | /// <summary> | ||
129 | /// | ||
130 | /// </summary> | ||
131 | /// <param name="UserInfo"></param> | ||
132 | public void RemoveAgent(UserAgentInfo userInfo) | ||
133 | { | ||
134 | this.AgentList.Remove(userInfo.AgentID); | ||
135 | |||
136 | //tell other clients to delete this avatar | ||
137 | } | ||
138 | |||
139 | /// <summary> | ||
140 | /// | ||
141 | /// </summary> | ||
142 | /// <param name="User_info"></param> | ||
143 | public void AgentJoin(UserAgentInfo userInfo) | ||
144 | { | ||
145 | //send region data | ||
146 | _server.SendPacket(RegionPacket,true, userInfo); | ||
147 | |||
148 | //inform client of join comlete | ||
149 | libsecondlife.Packets.AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); | ||
150 | mov.AgentData.SessionID = userInfo.SessionID; | ||
151 | mov.AgentData.AgentID = userInfo.AgentID; | ||
152 | mov.Data.RegionHandle = Globals.Instance.RegionHandle; | ||
153 | mov.Data.Timestamp = 1169838966; | ||
154 | mov.Data.Position = new LLVector3(100f, 100f, 22f); | ||
155 | mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0); | ||
156 | _server.SendPacket(mov, true, userInfo); | ||
157 | |||
158 | } | ||
159 | |||
160 | /// <summary> | ||
161 | /// | ||
162 | /// </summary> | ||
163 | public void UpdatePositions() | ||
164 | { | ||
165 | //update positions | ||
166 | foreach (KeyValuePair<libsecondlife.LLUUID, AvatarData> kp in this.AgentList) | ||
167 | { | ||
168 | |||
169 | kp.Value.Position.X += (kp.Value.Velocity.X * 0.2f); | ||
170 | kp.Value.Position.Y += (kp.Value.Velocity.Y * 0.2f); | ||
171 | kp.Value.Position.Z += (kp.Value.Velocity.Z * 0.2f); | ||
172 | } | ||
173 | |||
174 | } | ||
175 | |||
176 | public void UpdateAnim(UserAgentInfo userInfo, LLUUID AnimID, int AnimSeq) | ||
177 | { | ||
178 | AgentList[userInfo.AgentID].AnimID = AnimID; | ||
179 | AgentList[userInfo.AgentID].AnimSequenceID = AnimSeq; | ||
180 | UpdateAnim(userInfo); | ||
181 | } | ||
182 | |||
183 | public void UpdateAnim(UserAgentInfo userInfo) | ||
184 | { | ||
185 | Console.WriteLine("Agent_Manager.cs: UpdateAnim(UserAgentInfo userInfo): called for Agent " + userInfo.AgentID.ToString()); | ||
186 | AvatarAnimationPacket ani = new AvatarAnimationPacket(); | ||
187 | ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; | ||
188 | ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock(); | ||
189 | ani.AnimationSourceList[0].ObjectID = new LLUUID("00000000000000000000000000000000"); | ||
190 | ani.Sender = new AvatarAnimationPacket.SenderBlock(); | ||
191 | ani.Sender.ID = userInfo.AgentID; | ||
192 | ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1]; | ||
193 | ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock(); | ||
194 | ani.AnimationList[0].AnimID = AgentList[userInfo.AgentID].AnimID; | ||
195 | ani.AnimationList[0].AnimSequenceID = AgentList[userInfo.AgentID].AnimSequenceID; | ||
196 | Console.WriteLine("Agenct_Manager.cs: UpdateAnim(UserAgentInfo userInfo): Sent Animation to client - " + AgentManager.AnimsNames[ani.AnimationList[0].AnimID]); | ||
197 | _server.SendPacket(ani, true, userInfo); | ||
198 | |||
199 | // update other agents as appropiate | ||
200 | Axiom.MathLib.Sphere BoundingSphere; | ||
201 | foreach (KeyValuePair<libsecondlife.LLUUID, AvatarData> kp in this.AgentList) | ||
202 | { | ||
203 | if(kp.Key!=userInfo.AgentID) { | ||
204 | // Make a bounding sphere for the other avatar | ||
205 | BoundingSphere = new Sphere(new Vector3(kp.Value.Position.X,kp.Value.Position.Y,kp.Value.Position.Z), kp.Value.far); | ||
206 | |||
207 | // If it intersects with our position, send an update packet | ||
208 | if(BoundingSphere.Intersects(new Vector3(this.AgentList[userInfo.AgentID].Position.X,this.AgentList[userInfo.AgentID].Position.Y,this.AgentList[userInfo.AgentID].Position.Z))) { | ||
209 | ani.AnimationSourceList[0].ObjectID = userInfo.AgentID; | ||
210 | ani.Sender = new AvatarAnimationPacket.SenderBlock(); | ||
211 | ani.Sender.ID = userInfo.AgentID; | ||
212 | ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1]; | ||
213 | ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock(); | ||
214 | ani.AnimationList[0].AnimID = AgentList[userInfo.AgentID].AnimID; | ||
215 | ani.AnimationList[0].AnimSequenceID = AgentList[userInfo.AgentID].AnimSequenceID; | ||
216 | _server.SendPacket(ani, true, kp.Value.NetInfo); | ||
217 | } | ||
218 | } | ||
219 | } | ||
220 | } | ||
221 | /// <summary> | ||
222 | /// | ||
223 | /// </summary> | ||
224 | private void initialise() | ||
225 | { | ||
226 | //Region data | ||
227 | RegionPacket = new RegionHandshakePacket(); | ||
228 | RegionPacket.RegionInfo.BillableFactor = 0; | ||
229 | RegionPacket.RegionInfo.IsEstateManager = false; | ||
230 | RegionPacket.RegionInfo.TerrainHeightRange00 = 60; | ||
231 | RegionPacket.RegionInfo.TerrainHeightRange01 = 60; | ||
232 | RegionPacket.RegionInfo.TerrainHeightRange10 = 60; | ||
233 | RegionPacket.RegionInfo.TerrainHeightRange11 = 60; | ||
234 | RegionPacket.RegionInfo.TerrainStartHeight00 = 20; | ||
235 | RegionPacket.RegionInfo.TerrainStartHeight01 = 20; | ||
236 | RegionPacket.RegionInfo.TerrainStartHeight10 = 20; | ||
237 | RegionPacket.RegionInfo.TerrainStartHeight11 = 20; | ||
238 | RegionPacket.RegionInfo.SimAccess = 13; | ||
239 | RegionPacket.RegionInfo.WaterHeight = 5; | ||
240 | RegionPacket.RegionInfo.RegionFlags = 72458694; | ||
241 | RegionPacket.RegionInfo.SimName = _enc.GetBytes( Globals.Instance.RegionName); | ||
242 | RegionPacket.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
243 | RegionPacket.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); | ||
244 | RegionPacket.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); | ||
245 | RegionPacket.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); | ||
246 | RegionPacket.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); | ||
247 | RegionPacket.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
248 | RegionPacket.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
249 | RegionPacket.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
250 | RegionPacket.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
251 | RegionPacket.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37"); | ||
252 | |||
253 | this.SetupTemplate("objectupate168.dat"); | ||
254 | this.LoadAnims(); | ||
255 | } | ||
256 | |||
257 | /// <summary> | ||
258 | /// | ||
259 | /// </summary> | ||
260 | /// <param name="name"></param> | ||
261 | private void SetupTemplate(string name) | ||
262 | { | ||
263 | |||
264 | int i = 0; | ||
265 | FileInfo fInfo = new FileInfo(name); | ||
266 | long numBytes = fInfo.Length; | ||
267 | FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); | ||
268 | BinaryReader br = new BinaryReader(fStream); | ||
269 | byte [] data1 = br.ReadBytes((int)numBytes); | ||
270 | br.Close(); | ||
271 | fStream.Close(); | ||
272 | |||
273 | libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); | ||
274 | |||
275 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
276 | libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16); | ||
277 | pos.X = 100f; | ||
278 | objdata.ID = 8880000; | ||
279 | objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); | ||
280 | libsecondlife.LLVector3 pos2 = new LLVector3(13.981f,100.0f,20.0f); | ||
281 | //objdata.FullID=user.AgentID; | ||
282 | byte[] pb = pos.GetBytes(); | ||
283 | Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); | ||
284 | |||
285 | AvatarTemplate = objdata; | ||
286 | |||
287 | } | ||
288 | |||
289 | private void LoadAnims() | ||
290 | { | ||
291 | AnimsLLUUID.Add("ANIM_AGENT_AFRAID", new LLUUID("6b61c8e8-4747-0d75-12d7-e49ff207a4ca")); | ||
292 | AnimsLLUUID.Add("ANIM_AGENT_AIM_BAZOOKA_R", new LLUUID("b5b4a67d-0aee-30d2-72cd-77b333e932ef")); | ||
293 | AnimsLLUUID.Add("ANIM_AGENT_AIM_BOW_L", new LLUUID("46bb4359-de38-4ed8-6a22-f1f52fe8f506")); | ||
294 | AnimsLLUUID.Add("ANIM_AGENT_AIM_HANDGUN_R", new LLUUID("3147d815-6338-b932-f011-16b56d9ac18b")); | ||
295 | AnimsLLUUID.Add("ANIM_AGENT_AIM_RIFLE_R", new LLUUID("ea633413-8006-180a-c3ba-96dd1d756720")); | ||
296 | AnimsLLUUID.Add("ANIM_AGENT_ANGRY", new LLUUID("5747a48e-073e-c331-f6f3-7c2149613d3e")); | ||
297 | AnimsLLUUID.Add("ANIM_AGENT_AWAY", new LLUUID("fd037134-85d4-f241-72c6-4f42164fedee")); | ||
298 | AnimsLLUUID.Add("ANIM_AGENT_BACKFLIP", new LLUUID("c4ca6188-9127-4f31-0158-23c4e2f93304")); | ||
299 | AnimsLLUUID.Add("ANIM_AGENT_BELLY_LAUGH", new LLUUID("18b3a4b5-b463-bd48-e4b6-71eaac76c515")); | ||
300 | AnimsLLUUID.Add("ANIM_AGENT_BLOW_KISS", new LLUUID("db84829b-462c-ee83-1e27-9bbee66bd624")); | ||
301 | AnimsLLUUID.Add("ANIM_AGENT_BORED", new LLUUID("b906c4ba-703b-1940-32a3-0c7f7d791510")); | ||
302 | AnimsLLUUID.Add("ANIM_AGENT_BOW", new LLUUID("82e99230-c906-1403-4d9c-3889dd98daba")); | ||
303 | AnimsLLUUID.Add("ANIM_AGENT_BRUSH", new LLUUID("349a3801-54f9-bf2c-3bd0-1ac89772af01")); | ||
304 | AnimsLLUUID.Add("ANIM_AGENT_BUSY", new LLUUID("efcf670c-2d18-8128-973a-034ebc806b67")); | ||
305 | AnimsLLUUID.Add("ANIM_AGENT_CLAP", new LLUUID("9b0c1c4e-8ac7-7969-1494-28c874c4f668")); | ||
306 | AnimsLLUUID.Add("ANIM_AGENT_COURTBOW", new LLUUID("9ba1c942-08be-e43a-fb29-16ad440efc50")); | ||
307 | AnimsLLUUID.Add("ANIM_AGENT_CROUCH", new LLUUID("201f3fdf-cb1f-dbec-201f-7333e328ae7c")); | ||
308 | AnimsLLUUID.Add("ANIM_AGENT_CROUCHWALK", new LLUUID("47f5f6fb-22e5-ae44-f871-73aaaf4a6022")); | ||
309 | AnimsLLUUID.Add("ANIM_AGENT_CRY", new LLUUID("92624d3e-1068-f1aa-a5ec-8244585193ed")); | ||
310 | AnimsLLUUID.Add("ANIM_AGENT_CUSTOMIZE", new LLUUID("038fcec9-5ebd-8a8e-0e2e-6e71a0a1ac53")); | ||
311 | AnimsLLUUID.Add("ANIM_AGENT_CUSTOMIZE_DONE", new LLUUID("6883a61a-b27b-5914-a61e-dda118a9ee2c")); | ||
312 | AnimsLLUUID.Add("ANIM_AGENT_DANCE1", new LLUUID("b68a3d7c-de9e-fc87-eec8-543d787e5b0d")); | ||
313 | AnimsLLUUID.Add("ANIM_AGENT_DANCE2", new LLUUID("928cae18-e31d-76fd-9cc9-2f55160ff818")); | ||
314 | AnimsLLUUID.Add("ANIM_AGENT_DANCE3", new LLUUID("30047778-10ea-1af7-6881-4db7a3a5a114")); | ||
315 | AnimsLLUUID.Add("ANIM_AGENT_DANCE4", new LLUUID("951469f4-c7b2-c818-9dee-ad7eea8c30b7")); | ||
316 | AnimsLLUUID.Add("ANIM_AGENT_DANCE5", new LLUUID("4bd69a1d-1114-a0b4-625f-84e0a5237155")); | ||
317 | AnimsLLUUID.Add("ANIM_AGENT_DANCE6", new LLUUID("cd28b69b-9c95-bb78-3f94-8d605ff1bb12")); | ||
318 | AnimsLLUUID.Add("ANIM_AGENT_DANCE7", new LLUUID("a54d8ee2-28bb-80a9-7f0c-7afbbe24a5d6")); | ||
319 | AnimsLLUUID.Add("ANIM_AGENT_DANCE8", new LLUUID("b0dc417c-1f11-af36-2e80-7e7489fa7cdc")); | ||
320 | AnimsLLUUID.Add("ANIM_AGENT_DEAD", new LLUUID("57abaae6-1d17-7b1b-5f98-6d11a6411276")); | ||
321 | AnimsLLUUID.Add("ANIM_AGENT_DRINK", new LLUUID("0f86e355-dd31-a61c-fdb0-3a96b9aad05f")); | ||
322 | AnimsLLUUID.Add("ANIM_AGENT_EMBARRASSED", new LLUUID("514af488-9051-044a-b3fc-d4dbf76377c6")); | ||
323 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_AFRAID", new LLUUID("aa2df84d-cf8f-7218-527b-424a52de766e")); | ||
324 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_ANGER", new LLUUID("1a03b575-9634-b62a-5767-3a679e81f4de")); | ||
325 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_BORED", new LLUUID("214aa6c1-ba6a-4578-f27c-ce7688f61d0d")); | ||
326 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_CRY", new LLUUID("d535471b-85bf-3b4d-a542-93bea4f59d33")); | ||
327 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_DISDAIN", new LLUUID("d4416ff1-09d3-300f-4183-1b68a19b9fc1")); | ||
328 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_EMBARRASSED", new LLUUID("0b8c8211-d78c-33e8-fa28-c51a9594e424")); | ||
329 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_FROWN", new LLUUID("fee3df48-fa3d-1015-1e26-a205810e3001")); | ||
330 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_KISS", new LLUUID("1e8d90cc-a84e-e135-884c-7c82c8b03a14")); | ||
331 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_LAUGH", new LLUUID("62570842-0950-96f8-341c-809e65110823")); | ||
332 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_OPEN_MOUTH", new LLUUID("d63bc1f9-fc81-9625-a0c6-007176d82eb7")); | ||
333 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_REPULSED", new LLUUID("f76cda94-41d4-a229-2872-e0296e58afe1")); | ||
334 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_SAD", new LLUUID("eb6ebfb2-a4b3-a19c-d388-4dd5c03823f7")); | ||
335 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_SHRUG", new LLUUID("a351b1bc-cc94-aac2-7bea-a7e6ebad15ef")); | ||
336 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_SMILE", new LLUUID("b7c7c833-e3d3-c4e3-9fc0-131237446312")); | ||
337 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_SURPRISE", new LLUUID("728646d9-cc79-08b2-32d6-937f0a835c24")); | ||
338 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_TONGUE_OUT", new LLUUID("835965c6-7f2f-bda2-5deb-2478737f91bf")); | ||
339 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_TOOTHSMILE", new LLUUID("b92ec1a5-e7ce-a76b-2b05-bcdb9311417e")); | ||
340 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_WINK", new LLUUID("da020525-4d94-59d6-23d7-81fdebf33148")); | ||
341 | AnimsLLUUID.Add("ANIM_AGENT_EXPRESS_WORRY", new LLUUID("9c05e5c7-6f07-6ca4-ed5a-b230390c3950")); | ||
342 | AnimsLLUUID.Add("ANIM_AGENT_FALLDOWN", new LLUUID("666307d9-a860-572d-6fd4-c3ab8865c094")); | ||
343 | AnimsLLUUID.Add("ANIM_AGENT_FEMALE_WALK", new LLUUID("f5fc7433-043d-e819-8298-f519a119b688")); | ||
344 | AnimsLLUUID.Add("ANIM_AGENT_FINGER_WAG", new LLUUID("c1bc7f36-3ba0-d844-f93c-93be945d644f")); | ||
345 | AnimsLLUUID.Add("ANIM_AGENT_FIST_PUMP", new LLUUID("7db00ccd-f380-f3ee-439d-61968ec69c8a")); | ||
346 | AnimsLLUUID.Add("ANIM_AGENT_FLY", new LLUUID("aec4610c-757f-bc4e-c092-c6e9caf18daf")); | ||
347 | AnimsLLUUID.Add("ANIM_AGENT_FLYSLOW", new LLUUID("2b5a38b2-5e00-3a97-a495-4c826bc443e6")); | ||
348 | AnimsLLUUID.Add("ANIM_AGENT_HELLO", new LLUUID("9b29cd61-c45b-5689-ded2-91756b8d76a9")); | ||
349 | AnimsLLUUID.Add("ANIM_AGENT_HOLD_BAZOOKA_R", new LLUUID("ef62d355-c815-4816-2474-b1acc21094a6")); | ||
350 | AnimsLLUUID.Add("ANIM_AGENT_HOLD_BOW_L", new LLUUID("8b102617-bcba-037b-86c1-b76219f90c88")); | ||
351 | AnimsLLUUID.Add("ANIM_AGENT_HOLD_HANDGUN_R", new LLUUID("efdc1727-8b8a-c800-4077-975fc27ee2f2")); | ||
352 | AnimsLLUUID.Add("ANIM_AGENT_HOLD_RIFLE_R", new LLUUID("3d94bad0-c55b-7dcc-8763-033c59405d33")); | ||
353 | AnimsLLUUID.Add("ANIM_AGENT_HOLD_THROW_R", new LLUUID("7570c7b5-1f22-56dd-56ef-a9168241bbb6")); | ||
354 | AnimsLLUUID.Add("ANIM_AGENT_HOVER", new LLUUID("4ae8016b-31b9-03bb-c401-b1ea941db41d")); | ||
355 | AnimsLLUUID.Add("ANIM_AGENT_HOVER_DOWN", new LLUUID("20f063ea-8306-2562-0b07-5c853b37b31e")); | ||
356 | AnimsLLUUID.Add("ANIM_AGENT_HOVER_UP", new LLUUID("62c5de58-cb33-5743-3d07-9e4cd4352864")); | ||
357 | AnimsLLUUID.Add("ANIM_AGENT_IMPATIENT", new LLUUID("5ea3991f-c293-392e-6860-91dfa01278a3")); | ||
358 | AnimsLLUUID.Add("ANIM_AGENT_JUMP", new LLUUID("2305bd75-1ca9-b03b-1faa-b176b8a8c49e")); | ||
359 | AnimsLLUUID.Add("ANIM_AGENT_JUMP_FOR_JOY", new LLUUID("709ea28e-1573-c023-8bf8-520c8bc637fa")); | ||
360 | AnimsLLUUID.Add("ANIM_AGENT_KISS_MY_BUTT", new LLUUID("19999406-3a3a-d58c-a2ac-d72e555dcf51")); | ||
361 | AnimsLLUUID.Add("ANIM_AGENT_LAND", new LLUUID("7a17b059-12b2-41b1-570a-186368b6aa6f")); | ||
362 | AnimsLLUUID.Add("ANIM_AGENT_LAUGH_SHORT", new LLUUID("ca5b3f14-3194-7a2b-c894-aa699b718d1f")); | ||
363 | AnimsLLUUID.Add("ANIM_AGENT_MEDIUM_LAND", new LLUUID("f4f00d6e-b9fe-9292-f4cb-0ae06ea58d57")); | ||
364 | AnimsLLUUID.Add("ANIM_AGENT_MOTORCYCLE_SIT", new LLUUID("08464f78-3a8e-2944-cba5-0c94aff3af29")); | ||
365 | AnimsLLUUID.Add("ANIM_AGENT_MUSCLE_BEACH", new LLUUID("315c3a41-a5f3-0ba4-27da-f893f769e69b")); | ||
366 | AnimsLLUUID.Add("ANIM_AGENT_NO", new LLUUID("5a977ed9-7f72-44e9-4c4c-6e913df8ae74")); | ||
367 | AnimsLLUUID.Add("ANIM_AGENT_NO_UNHAPPY", new LLUUID("d83fa0e5-97ed-7eb2-e798-7bd006215cb4")); | ||
368 | AnimsLLUUID.Add("ANIM_AGENT_NYAH_NYAH", new LLUUID("f061723d-0a18-754f-66ee-29a44795a32f")); | ||
369 | AnimsLLUUID.Add("ANIM_AGENT_ONETWO_PUNCH", new LLUUID("eefc79be-daae-a239-8c04-890f5d23654a")); | ||
370 | AnimsLLUUID.Add("ANIM_AGENT_PEACE", new LLUUID("b312b10e-65ab-a0a4-8b3c-1326ea8e3ed9")); | ||
371 | AnimsLLUUID.Add("ANIM_AGENT_POINT_ME", new LLUUID("17c024cc-eef2-f6a0-3527-9869876d7752")); | ||
372 | AnimsLLUUID.Add("ANIM_AGENT_POINT_YOU", new LLUUID("ec952cca-61ef-aa3b-2789-4d1344f016de")); | ||
373 | AnimsLLUUID.Add("ANIM_AGENT_PRE_JUMP", new LLUUID("7a4e87fe-de39-6fcb-6223-024b00893244")); | ||
374 | AnimsLLUUID.Add("ANIM_AGENT_PUNCH_LEFT", new LLUUID("f3300ad9-3462-1d07-2044-0fef80062da0")); | ||
375 | AnimsLLUUID.Add("ANIM_AGENT_PUNCH_RIGHT", new LLUUID("c8e42d32-7310-6906-c903-cab5d4a34656")); | ||
376 | AnimsLLUUID.Add("ANIM_AGENT_REPULSED", new LLUUID("36f81a92-f076-5893-dc4b-7c3795e487cf")); | ||
377 | AnimsLLUUID.Add("ANIM_AGENT_ROUNDHOUSE_KICK", new LLUUID("49aea43b-5ac3-8a44-b595-96100af0beda")); | ||
378 | AnimsLLUUID.Add("ANIM_AGENT_RPS_COUNTDOWN", new LLUUID("35db4f7e-28c2-6679-cea9-3ee108f7fc7f")); | ||
379 | AnimsLLUUID.Add("ANIM_AGENT_RPS_PAPER", new LLUUID("0836b67f-7f7b-f37b-c00a-460dc1521f5a")); | ||
380 | AnimsLLUUID.Add("ANIM_AGENT_RPS_ROCK", new LLUUID("42dd95d5-0bc6-6392-f650-777304946c0f")); | ||
381 | AnimsLLUUID.Add("ANIM_AGENT_RPS_SCISSORS", new LLUUID("16803a9f-5140-e042-4d7b-d28ba247c325")); | ||
382 | AnimsLLUUID.Add("ANIM_AGENT_RUN", new LLUUID("05ddbff8-aaa9-92a1-2b74-8fe77a29b445")); | ||
383 | AnimsLLUUID.Add("ANIM_AGENT_SAD", new LLUUID("0eb702e2-cc5a-9a88-56a5-661a55c0676a")); | ||
384 | AnimsLLUUID.Add("ANIM_AGENT_SALUTE", new LLUUID("cd7668a6-7011-d7e2-ead8-fc69eff1a104")); | ||
385 | AnimsLLUUID.Add("ANIM_AGENT_SHOOT_BOW_L", new LLUUID("e04d450d-fdb5-0432-fd68-818aaf5935f8")); | ||
386 | AnimsLLUUID.Add("ANIM_AGENT_SHOUT", new LLUUID("6bd01860-4ebd-127a-bb3d-d1427e8e0c42")); | ||
387 | AnimsLLUUID.Add("ANIM_AGENT_SHRUG", new LLUUID("70ea714f-3a97-d742-1b01-590a8fcd1db5")); | ||
388 | AnimsLLUUID.Add("ANIM_AGENT_SIT", new LLUUID("1a5fe8ac-a804-8a5d-7cbd-56bd83184568")); | ||
389 | AnimsLLUUID.Add("ANIM_AGENT_SIT_FEMALE", new LLUUID("b1709c8d-ecd3-54a1-4f28-d55ac0840782")); | ||
390 | AnimsLLUUID.Add("ANIM_AGENT_SIT_GENERIC", new LLUUID("245f3c54-f1c0-bf2e-811f-46d8eeb386e7")); | ||
391 | AnimsLLUUID.Add("ANIM_AGENT_SIT_GROUND", new LLUUID("1c7600d6-661f-b87b-efe2-d7421eb93c86")); | ||
392 | AnimsLLUUID.Add("ANIM_AGENT_SIT_GROUND_CONSTRAINED", new LLUUID("1a2bd58e-87ff-0df8-0b4c-53e047b0bb6e")); | ||
393 | AnimsLLUUID.Add("ANIM_AGENT_SIT_TO_STAND", new LLUUID("a8dee56f-2eae-9e7a-05a2-6fb92b97e21e")); | ||
394 | AnimsLLUUID.Add("ANIM_AGENT_SLEEP", new LLUUID("f2bed5f9-9d44-39af-b0cd-257b2a17fe40")); | ||
395 | AnimsLLUUID.Add("ANIM_AGENT_SMOKE_IDLE", new LLUUID("d2f2ee58-8ad1-06c9-d8d3-3827ba31567a")); | ||
396 | AnimsLLUUID.Add("ANIM_AGENT_SMOKE_INHALE", new LLUUID("6802d553-49da-0778-9f85-1599a2266526")); | ||
397 | AnimsLLUUID.Add("ANIM_AGENT_SMOKE_THROW_DOWN", new LLUUID("0a9fb970-8b44-9114-d3a9-bf69cfe804d6")); | ||
398 | AnimsLLUUID.Add("ANIM_AGENT_SNAPSHOT", new LLUUID("eae8905b-271a-99e2-4c0e-31106afd100c")); | ||
399 | AnimsLLUUID.Add("ANIM_AGENT_STAND", new LLUUID("2408fe9e-df1d-1d7d-f4ff-1384fa7b350f")); | ||
400 | AnimsLLUUID.Add("ANIM_AGENT_STANDUP", new LLUUID("3da1d753-028a-5446-24f3-9c9b856d9422")); | ||
401 | AnimsLLUUID.Add("ANIM_AGENT_STAND_1", new LLUUID("15468e00-3400-bb66-cecc-646d7c14458e")); | ||
402 | AnimsLLUUID.Add("ANIM_AGENT_STAND_2", new LLUUID("370f3a20-6ca6-9971-848c-9a01bc42ae3c")); | ||
403 | AnimsLLUUID.Add("ANIM_AGENT_STAND_3", new LLUUID("42b46214-4b44-79ae-deb8-0df61424ff4b")); | ||
404 | AnimsLLUUID.Add("ANIM_AGENT_STAND_4", new LLUUID("f22fed8b-a5ed-2c93-64d5-bdd8b93c889f")); | ||
405 | AnimsLLUUID.Add("ANIM_AGENT_STRETCH", new LLUUID("80700431-74ec-a008-14f8-77575e73693f")); | ||
406 | AnimsLLUUID.Add("ANIM_AGENT_STRIDE", new LLUUID("1cb562b0-ba21-2202-efb3-30f82cdf9595")); | ||
407 | AnimsLLUUID.Add("ANIM_AGENT_SURF", new LLUUID("41426836-7437-7e89-025d-0aa4d10f1d69")); | ||
408 | AnimsLLUUID.Add("ANIM_AGENT_SURPRISE", new LLUUID("313b9881-4302-73c0-c7d0-0e7a36b6c224")); | ||
409 | AnimsLLUUID.Add("ANIM_AGENT_SWORD_STRIKE", new LLUUID("85428680-6bf9-3e64-b489-6f81087c24bd")); | ||
410 | AnimsLLUUID.Add("ANIM_AGENT_TALK", new LLUUID("5c682a95-6da4-a463-0bf6-0f5b7be129d1")); | ||
411 | AnimsLLUUID.Add("ANIM_AGENT_TANTRUM", new LLUUID("11000694-3f41-adc2-606b-eee1d66f3724")); | ||
412 | AnimsLLUUID.Add("ANIM_AGENT_THROW_R", new LLUUID("aa134404-7dac-7aca-2cba-435f9db875ca")); | ||
413 | AnimsLLUUID.Add("ANIM_AGENT_TRYON_SHIRT", new LLUUID("83ff59fe-2346-f236-9009-4e3608af64c1")); | ||
414 | AnimsLLUUID.Add("ANIM_AGENT_TURNLEFT", new LLUUID("56e0ba0d-4a9f-7f27-6117-32f2ebbf6135")); | ||
415 | AnimsLLUUID.Add("ANIM_AGENT_TURNRIGHT", new LLUUID("2d6daa51-3192-6794-8e2e-a15f8338ec30")); | ||
416 | AnimsLLUUID.Add("ANIM_AGENT_TYPE", new LLUUID("c541c47f-e0c0-058b-ad1a-d6ae3a4584d9")); | ||
417 | AnimsLLUUID.Add("ANIM_AGENT_WALK", new LLUUID("6ed24bd8-91aa-4b12-ccc7-c97c857ab4e0")); | ||
418 | AnimsLLUUID.Add("ANIM_AGENT_WHISPER", new LLUUID("7693f268-06c7-ea71-fa21-2b30d6533f8f")); | ||
419 | AnimsLLUUID.Add("ANIM_AGENT_WHISTLE", new LLUUID("b1ed7982-c68e-a982-7561-52a88a5298c0")); | ||
420 | AnimsLLUUID.Add("ANIM_AGENT_WINK", new LLUUID("869ecdad-a44b-671e-3266-56aef2e3ac2e")); | ||
421 | AnimsLLUUID.Add("ANIM_AGENT_WINK_HOLLYWOOD", new LLUUID("c0c4030f-c02b-49de-24ba-2331f43fe41c")); | ||
422 | AnimsLLUUID.Add("ANIM_AGENT_WORRY", new LLUUID("9f496bd2-589a-709f-16cc-69bf7df1d36c")); | ||
423 | AnimsLLUUID.Add("ANIM_AGENT_YES", new LLUUID("15dd911d-be82-2856-26db-27659b142875")); | ||
424 | AnimsLLUUID.Add("ANIM_AGENT_YES_HAPPY", new LLUUID("b8c8b2a3-9008-1771-3bfc-90924955ab2d")); | ||
425 | AnimsLLUUID.Add("ANIM_AGENT_YOGA_FLOAT", new LLUUID("42ecd00b-9947-a97c-400a-bbc9174c7aeb")); | ||
426 | |||
427 | |||
428 | foreach (KeyValuePair<string, LLUUID> kp in AgentManager.AnimsLLUUID) | ||
429 | { | ||
430 | AnimsNames.Add(kp.Value, kp.Key); | ||
431 | } | ||
432 | } | ||
433 | |||
434 | /// <summary> | ||
435 | /// | ||
436 | /// </summary> | ||
437 | /// <param name="User_info"></param> | ||
438 | public void SendInitialData(UserAgentInfo userInfo) | ||
439 | { | ||
440 | |||
441 | //shouldn't have to read all this in from disk for every new client | ||
442 | string data_path = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, @"layer_data"); | ||
443 | |||
444 | //send layerdata | ||
445 | LayerDataPacket layerpack = new LayerDataPacket(); | ||
446 | layerpack.LayerID.Type = 76; | ||
447 | this.SendLayerData(userInfo,ref layerpack, System.IO.Path.Combine(data_path, @"layerdata0.dat")); | ||
448 | |||
449 | LayerDataPacket layerpack1 = new LayerDataPacket(); | ||
450 | layerpack1.LayerID.Type = 76; | ||
451 | this.SendLayerData(userInfo, ref layerpack, System.IO.Path.Combine(data_path, @"layerdata1.dat")); | ||
452 | |||
453 | LayerDataPacket layerpack2 = new LayerDataPacket(); | ||
454 | layerpack2.LayerID.Type = 56; | ||
455 | this.SendLayerData(userInfo, ref layerpack, System.IO.Path.Combine(data_path, @"layerdata2.dat")); | ||
456 | |||
457 | LayerDataPacket layerpack3 = new LayerDataPacket(); | ||
458 | layerpack3.LayerID.Type = 55; | ||
459 | this.SendLayerData(userInfo, ref layerpack, System.IO.Path.Combine(data_path, @"layerdata3.dat")); | ||
460 | |||
461 | LayerDataPacket layerpack4 = new LayerDataPacket(); | ||
462 | layerpack4.LayerID.Type = 56; | ||
463 | this.SendLayerData(userInfo, ref layerpack, System.IO.Path.Combine(data_path, @"layerdata4.dat")); | ||
464 | |||
465 | LayerDataPacket layerpack5 = new LayerDataPacket(); | ||
466 | layerpack5.LayerID.Type = 55; | ||
467 | this.SendLayerData(userInfo, ref layerpack, System.IO.Path.Combine(data_path, @"layerdata5.dat")); | ||
468 | |||
469 | //send intial set of captured prims data? | ||
470 | this.Prim_Manager.ReadPrimDatabase( "objectdatabase.ini", userInfo); | ||
471 | |||
472 | //send prims that have been created by users | ||
473 | //prim_man.send_existing_prims(User_info); | ||
474 | |||
475 | //send update about clients avatar | ||
476 | this.SendInitialAvatarPosition(userInfo); | ||
477 | |||
478 | //send updates about all other users | ||
479 | foreach (KeyValuePair<libsecondlife.LLUUID, AvatarData> kp in this.AgentList) | ||
480 | { | ||
481 | if(kp.Value.NetInfo.AgentID != userInfo.AgentID) | ||
482 | { | ||
483 | this.SendOtherAvatarPosition(userInfo, kp.Value); | ||
484 | } | ||
485 | } | ||
486 | } | ||
487 | |||
488 | /// <summary> | ||
489 | /// | ||
490 | /// </summary> | ||
491 | /// <param name="User_info"></param> | ||
492 | public void SendInitialAvatarPosition(UserAgentInfo userInfo) | ||
493 | { | ||
494 | //send a objectupdate packet with information about the clients avatar | ||
495 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
496 | objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle; | ||
497 | objupdate.RegionData.TimeDilation = 64096; | ||
498 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
499 | |||
500 | objupdate.ObjectData[0] = AvatarTemplate; | ||
501 | //give this avatar object a local id and assign the user a name | ||
502 | objupdate.ObjectData[0].ID = 8880000 + this._localNumber; | ||
503 | userInfo.localID = objupdate.ObjectData[0].ID; | ||
504 | //User_info.name="Test"+this.local_numer+" User"; | ||
505 | this.GetAgent(userInfo.AgentID).Started = true; | ||
506 | objupdate.ObjectData[0].FullID = userInfo.AgentID; | ||
507 | objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + userInfo.first_name + "\nLastName STRING RW SV " + userInfo.last_name + " \0"); | ||
508 | userInfo.name = "FirstName STRING RW SV " + userInfo.first_name + "\nLastName STRING RW SV " + userInfo.last_name + " \0"; | ||
509 | |||
510 | libsecondlife.LLVector3 pos2 = new LLVector3(100f, 100.0f, 22.0f); | ||
511 | |||
512 | byte[] pb = pos2.GetBytes(); | ||
513 | |||
514 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); | ||
515 | this._localNumber++; | ||
516 | |||
517 | _server.SendPacket(objupdate, true, userInfo); | ||
518 | |||
519 | //send this info to other existing clients | ||
520 | foreach (KeyValuePair<libsecondlife.LLUUID, AvatarData> kp in this.AgentList) | ||
521 | { | ||
522 | if(kp.Value.NetInfo.AgentID != userInfo.AgentID) | ||
523 | { | ||
524 | _server.SendPacket(objupdate, true, kp.Value.NetInfo); | ||
525 | this.SendOtherAppearance(kp.Value.NetInfo, objupdate.ObjectData[0].FullID); | ||
526 | } | ||
527 | } | ||
528 | |||
529 | } | ||
530 | |||
531 | /// <summary> | ||
532 | /// | ||
533 | /// </summary> | ||
534 | /// <param name="user"></param> | ||
535 | public void SendIntialAvatarAppearance(UserAgentInfo userInfo) | ||
536 | { | ||
537 | AvatarData Agent = this.AgentList[userInfo.AgentID]; | ||
538 | AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); | ||
539 | aw.AgentData.AgentID = userInfo.AgentID; | ||
540 | aw.AgentData.SerialNum = 0; | ||
541 | aw.AgentData.SessionID = userInfo.SessionID; | ||
542 | |||
543 | aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; | ||
544 | AgentWearablesUpdatePacket.WearableDataBlock awb = null; | ||
545 | awb = new AgentWearablesUpdatePacket.WearableDataBlock(); | ||
546 | awb.WearableType = (byte)0; | ||
547 | awb.AssetID = Agent.Wearables[0].AssetID; | ||
548 | awb.ItemID = Agent.Wearables[0].ItemID; | ||
549 | aw.WearableData[0] = awb; | ||
550 | |||
551 | awb = new AgentWearablesUpdatePacket.WearableDataBlock(); | ||
552 | awb.WearableType =(byte)1; | ||
553 | awb.AssetID = Agent.Wearables[1].AssetID; | ||
554 | awb.ItemID = Agent.Wearables[1].ItemID; | ||
555 | aw.WearableData[1] = awb; | ||
556 | |||
557 | for(int i=2; i<13; i++) | ||
558 | { | ||
559 | awb = new AgentWearablesUpdatePacket.WearableDataBlock(); | ||
560 | awb.WearableType = (byte)i; | ||
561 | awb.AssetID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
562 | awb.ItemID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
563 | aw.WearableData[i] = awb; | ||
564 | } | ||
565 | |||
566 | _server.SendPacket(aw, true, userInfo); | ||
567 | } | ||
568 | |||
569 | /// <summary> | ||
570 | /// | ||
571 | /// </summary> | ||
572 | /// <param name="user"></param> | ||
573 | /// <param name="id"></param> | ||
574 | public void SendOtherAppearance(UserAgentInfo userInfo, LLUUID id) | ||
575 | { | ||
576 | AvatarAppearancePacket avp = new AvatarAppearancePacket(); | ||
577 | |||
578 | |||
579 | avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; | ||
580 | //avp.ObjectData.TextureEntry=this.avatar_template.TextureEntry;// br.ReadBytes((int)numBytes); | ||
581 | |||
582 | FileInfo fInfo = new FileInfo("Avatar_texture3.dat"); | ||
583 | long numBytes = fInfo.Length; | ||
584 | FileStream fStream = new FileStream("Avatar_texture3.dat", FileMode.Open, FileAccess.Read); | ||
585 | BinaryReader br = new BinaryReader(fStream); | ||
586 | avp.ObjectData.TextureEntry = br.ReadBytes((int)numBytes); | ||
587 | br.Close(); | ||
588 | fStream.Close(); | ||
589 | |||
590 | AvatarAppearancePacket.VisualParamBlock avblock = null; | ||
591 | for(int i = 0; i < 218; i++) | ||
592 | { | ||
593 | avblock = new AvatarAppearancePacket.VisualParamBlock(); | ||
594 | avblock.ParamValue = (byte)100; | ||
595 | avp.VisualParam[i] = avblock; | ||
596 | } | ||
597 | |||
598 | avp.Sender.IsTrial = false; | ||
599 | avp.Sender.ID = id; | ||
600 | _server.SendPacket(avp, true, userInfo); | ||
601 | |||
602 | } | ||
603 | |||
604 | /// <summary> | ||
605 | /// | ||
606 | /// </summary> | ||
607 | /// <param name="User_info"></param> | ||
608 | /// <param name="avd"></param> | ||
609 | public void SendOtherAvatarPosition(UserAgentInfo userInfo, AvatarData avatar) | ||
610 | { | ||
611 | //send a objectupdate packet with information about the clients avatar | ||
612 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
613 | objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle; | ||
614 | objupdate.RegionData.TimeDilation = 64500; | ||
615 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
616 | |||
617 | objupdate.ObjectData[0] = AvatarTemplate; | ||
618 | //give this avatar object a local id and assign the user a name | ||
619 | objupdate.ObjectData[0].ID = avatar.NetInfo.localID; | ||
620 | objupdate.ObjectData[0].FullID = avatar.NetInfo.AgentID; | ||
621 | objupdate.ObjectData[0].NameValue = _enc.GetBytes(avatar.NetInfo.name); | ||
622 | libsecondlife.LLVector3 pos2 = new LLVector3(avatar.Position.X, avatar.Position.Y, avatar.Position.Z); | ||
623 | |||
624 | byte[] pb = pos2.GetBytes(); | ||
625 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); | ||
626 | this._localNumber++; | ||
627 | |||
628 | _server.SendPacket(objupdate, true, userInfo); | ||
629 | this.SendOtherAppearance(userInfo, avatar.NetInfo.AgentID); | ||
630 | |||
631 | } | ||
632 | |||
633 | /// <summary> | ||
634 | /// | ||
635 | /// </summary> | ||
636 | /// <param name="User_info"></param> | ||
637 | /// <param name="line"></param> | ||
638 | public void SendChatMessage(UserAgentInfo userInfo, string line) | ||
639 | { | ||
640 | libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); | ||
641 | reply.ChatData.Audible = 1; | ||
642 | reply.ChatData.Message = _enc.GetBytes(line); | ||
643 | reply.ChatData.ChatType = 1; | ||
644 | reply.ChatData.SourceType = 1; | ||
645 | reply.ChatData.Position = new LLVector3(120, 100, 21); //should set to actual position | ||
646 | reply.ChatData.FromName = _enc.GetBytes(userInfo.first_name + " " + userInfo.last_name + "\0"); | ||
647 | reply.ChatData.OwnerID = userInfo.AgentID; | ||
648 | reply.ChatData.SourceID = userInfo.AgentID; | ||
649 | //echo to sender | ||
650 | _server.SendPacket(reply, true, userInfo); | ||
651 | |||
652 | //send to all users | ||
653 | foreach (KeyValuePair<libsecondlife.LLUUID, AvatarData> kp in this.AgentList) | ||
654 | { | ||
655 | if(kp.Value.NetInfo.AgentID!=userInfo.AgentID) | ||
656 | { | ||
657 | _server.SendPacket(reply, true, kp.Value.NetInfo); | ||
658 | } | ||
659 | } | ||
660 | } | ||
661 | |||
662 | /// <summary> | ||
663 | /// | ||
664 | /// </summary> | ||
665 | /// <param name="user"></param> | ||
666 | /// <param name="stop"></param> | ||
667 | /// <param name="x"></param> | ||
668 | /// <param name="y"></param> | ||
669 | /// <param name="z"></param> | ||
670 | /// <param name="av_id"></param> | ||
671 | /// <param name="body"></param> | ||
672 | public void SendMoveCommand(UserAgentInfo userInfo, bool stop, float x, float y, float z, uint avatarID, libsecondlife.LLQuaternion body) | ||
673 | { | ||
674 | Console.WriteLine("sending move"); | ||
675 | uint ID = userInfo.localID; | ||
676 | byte[] bytes = new byte[60]; | ||
677 | int i=0; | ||
678 | |||
679 | ImprovedTerseObjectUpdatePacket im = new ImprovedTerseObjectUpdatePacket(); | ||
680 | im.RegionData.RegionHandle = Globals.Instance.RegionHandle;; | ||
681 | im.RegionData.TimeDilation = 64096; | ||
682 | |||
683 | im.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
684 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | ||
685 | |||
686 | im.ObjectData[0] = dat; | ||
687 | |||
688 | dat.TextureEntry = AvatarTemplate.TextureEntry; | ||
689 | libsecondlife.LLVector3 pos2 = new LLVector3(x, y, z); | ||
690 | |||
691 | bytes[i++] = (byte)(ID % 256); | ||
692 | bytes[i++] = (byte)((ID >> 8) % 256); | ||
693 | bytes[i++] = (byte)((ID >> 16) % 256); | ||
694 | bytes[i++] = (byte)((ID >> 24) % 256); | ||
695 | |||
696 | bytes[i++] = 0; | ||
697 | bytes[i++] = 1; | ||
698 | |||
699 | i += 14; | ||
700 | bytes[i++] = 128; | ||
701 | bytes[i++] = 63; | ||
702 | byte[] pb = pos2.GetBytes(); | ||
703 | |||
704 | Array.Copy(pb, 0, bytes, i, pb.Length); | ||
705 | i += 12; | ||
706 | ushort ac = 32767; | ||
707 | Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0); | ||
708 | Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(body.W, body.X, body.Y, body.Z); | ||
709 | Axiom.MathLib.Vector3 direc = q * v3; | ||
710 | direc.Normalize(); | ||
711 | |||
712 | direc = direc * (0.03f); | ||
713 | direc.x += 1; | ||
714 | direc.y += 1; | ||
715 | direc.z += 1; | ||
716 | ushort dx, dy, dz; | ||
717 | dx = (ushort)(32768 * direc.x); | ||
718 | dy = (ushort)(32768 * direc.y); | ||
719 | dz = (ushort)(32768 * direc.z); | ||
720 | |||
721 | //vel | ||
722 | if(!stop) | ||
723 | { | ||
724 | bytes[i++] = (byte)(dx % 256); | ||
725 | bytes[i++] = (byte)((dx >> 8) % 256); | ||
726 | |||
727 | bytes[i++] = (byte)(dy % 256); | ||
728 | bytes[i++] = (byte)((dy >> 8) % 256); | ||
729 | |||
730 | bytes[i++] = (byte)(dz % 256); | ||
731 | bytes[i++] = (byte)((dz >> 8) % 256); | ||
732 | } | ||
733 | else | ||
734 | { | ||
735 | bytes[i++] = (byte)(ac % 256); | ||
736 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
737 | |||
738 | bytes[i++] = (byte)(ac % 256); | ||
739 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
740 | |||
741 | bytes[i++] = (byte)(ac % 256); | ||
742 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
743 | } | ||
744 | //accel | ||
745 | bytes[i++] = (byte)(ac % 256); | ||
746 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
747 | |||
748 | bytes[i++] = (byte)(ac % 256); | ||
749 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
750 | |||
751 | bytes[i++] = (byte)(ac % 256); | ||
752 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
753 | |||
754 | //rot | ||
755 | bytes[i++] = (byte)(ac % 256); | ||
756 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
757 | |||
758 | bytes[i++] = (byte)(ac % 256); | ||
759 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
760 | |||
761 | bytes[i++] = (byte)(ac % 256); | ||
762 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
763 | |||
764 | bytes[i++] = (byte)(ac % 256); | ||
765 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
766 | |||
767 | //rotation vel | ||
768 | bytes[i++] = (byte)(ac % 256); | ||
769 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
770 | |||
771 | bytes[i++] = (byte)(ac % 256); | ||
772 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
773 | |||
774 | bytes[i++] = (byte)(ac % 256); | ||
775 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
776 | |||
777 | dat.Data=bytes; | ||
778 | |||
779 | _server.SendPacket(im, true, userInfo); | ||
780 | |||
781 | //should send to all users. | ||
782 | foreach (KeyValuePair<libsecondlife.LLUUID, AvatarData> kp in this.AgentList) | ||
783 | { | ||
784 | if(kp.Value.NetInfo.AgentID != userInfo.AgentID) | ||
785 | { | ||
786 | _server.SendPacket(im, true, kp.Value.NetInfo); | ||
787 | } | ||
788 | } | ||
789 | |||
790 | //check if we should be standing or walking | ||
791 | if (this.AgentList[userInfo.AgentID].Walk) | ||
792 | { | ||
793 | this.AgentList[userInfo.AgentID].AnimID = AgentManager.AnimsLLUUID["ANIM_AGENT_WALK"]; | ||
794 | this.AgentList[userInfo.AgentID].AnimSequenceID = 1; | ||
795 | this.UpdateAnim(userInfo); | ||
796 | } | ||
797 | else | ||
798 | { | ||
799 | this.AgentList[userInfo.AgentID].AnimID = AgentManager.AnimsLLUUID["ANIM_AGENT_STAND"]; | ||
800 | this.AgentList[userInfo.AgentID].AnimSequenceID = 1; | ||
801 | this.UpdateAnim(userInfo); | ||
802 | } | ||
803 | } | ||
804 | |||
805 | /// <summary> | ||
806 | /// | ||
807 | /// </summary> | ||
808 | /// <param name="User_info"></param> | ||
809 | /// <param name="lay"></param> | ||
810 | /// <param name="name"></param> | ||
811 | public void SendLayerData(UserAgentInfo userInfo, ref LayerDataPacket layer, string name) | ||
812 | { | ||
813 | FileInfo fInfo = new FileInfo(name); | ||
814 | long numBytes = fInfo.Length; | ||
815 | FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); | ||
816 | BinaryReader br = new BinaryReader(fStream); | ||
817 | byte [] data1 = br.ReadBytes((int)numBytes); | ||
818 | br.Close(); | ||
819 | fStream.Close(); | ||
820 | layer.LayerData.Data = data1; | ||
821 | _server.SendPacket(layer, true, userInfo); | ||
822 | |||
823 | } | ||
824 | } | ||
825 | |||
826 | public class AvatarData | ||
827 | { | ||
828 | public UserAgentInfo NetInfo; | ||
829 | public LLUUID FullID; | ||
830 | public LLVector3 Position; | ||
831 | public LLVector3 Velocity = new LLVector3(0,0,0); | ||
832 | //public LLQuaternion Rotation; | ||
833 | public bool Walk = false; | ||
834 | public bool Started = false; | ||
835 | //public TextureEntry TextureEntry; | ||
836 | public AvatarWearable[] Wearables; | ||
837 | public LLUUID InventoryFolder; | ||
838 | public LLUUID BaseFolder; | ||
839 | public LLUUID AnimID; | ||
840 | public int AnimSequenceID; | ||
841 | public float far; | ||
842 | public libsecondlife.LLVector3 CameraAtAxis; | ||
843 | public libsecondlife.LLVector3 CameraCenter; | ||
844 | public libsecondlife.LLVector3 CameraLeftAxis; | ||
845 | public libsecondlife.LLVector3 CameraUpAxis; | ||
846 | |||
847 | public AvatarData() | ||
848 | { | ||
849 | Wearables=new AvatarWearable[2]; //should be 13 | ||
850 | for(int i = 0; i < 2; i++) | ||
851 | { | ||
852 | Wearables[i] = new AvatarWearable(); | ||
853 | } | ||
854 | } | ||
855 | } | ||
856 | |||
857 | public class AvatarWearable | ||
858 | { | ||
859 | public LLUUID AssetID; | ||
860 | public LLUUID ItemID; | ||
861 | |||
862 | public AvatarWearable() | ||
863 | { | ||
864 | |||
865 | } | ||
866 | } | ||
867 | /* | ||
868 | public class AvatarParams | ||
869 | { | ||
870 | public byte[] Params; | ||
871 | |||
872 | public AvatarParams() | ||
873 | { | ||
874 | |||
875 | } | ||
876 | |||
877 | } | ||
878 | */ | ||
879 | } | ||
diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs deleted file mode 100644 index 3fc9cb3..0000000 --- a/AssemblyInfo.cs +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) <year>, <copyright holder> | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the <organization> nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | |||
27 | */ | ||
28 | |||
29 | using System.Reflection; | ||
30 | using System.Runtime.CompilerServices; | ||
31 | using System.Runtime.InteropServices; | ||
32 | |||
33 | // Information about this assembly is defined by the following | ||
34 | // attributes. | ||
35 | // | ||
36 | // change them to the information which is associated with the assembly | ||
37 | // you compile. | ||
38 | |||
39 | [assembly: AssemblyTitle("OpenSim")] | ||
40 | [assembly: AssemblyDescription("")] | ||
41 | [assembly: AssemblyConfiguration("")] | ||
42 | [assembly: AssemblyCompany("")] | ||
43 | [assembly: AssemblyProduct("OpenSim")] | ||
44 | [assembly: AssemblyCopyright("")] | ||
45 | [assembly: AssemblyTrademark("")] | ||
46 | [assembly: AssemblyCulture("")] | ||
47 | |||
48 | // This sets the default COM visibility of types in the assembly to invisible. | ||
49 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. | ||
50 | [assembly: ComVisible(false)] | ||
51 | |||
52 | // The assembly version has following format : | ||
53 | // | ||
54 | // Major.Minor.Build.Revision | ||
55 | // | ||
56 | // You can specify all values by your own or you can build default build and revision | ||
57 | // numbers with the '*' character (the default): | ||
58 | |||
59 | [assembly: AssemblyVersion("0.1.*")] | ||
diff --git a/AssetManagement.cs b/AssetManagement.cs deleted file mode 100644 index 0656494..0000000 --- a/AssetManagement.cs +++ /dev/null | |||
@@ -1,469 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the <organization> nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using libsecondlife; | ||
32 | using System.Collections; | ||
33 | using libsecondlife.Packets; | ||
34 | using libsecondlife.AssetSystem; | ||
35 | using System.IO; | ||
36 | |||
37 | namespace OpenSim | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// Asset and Image management | ||
41 | /// </summary> | ||
42 | public class AssetManagement | ||
43 | { | ||
44 | public Dictionary<libsecondlife.LLUUID,AssetInfo> Assets; | ||
45 | public Dictionary<libsecondlife.LLUUID,TextureImage> Textures; | ||
46 | |||
47 | public ArrayList AssetRequests = new ArrayList(); //should change to a generic | ||
48 | public ArrayList TextureRequests = new ArrayList(); | ||
49 | //public ArrayList uploads=new ArrayList(); | ||
50 | private Server _server; | ||
51 | private InventoryManager _inventoryManager; | ||
52 | private System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
53 | |||
54 | /// <summary> | ||
55 | /// | ||
56 | /// </summary> | ||
57 | /// <param name="_server"></param> | ||
58 | public AssetManagement(Server server, InventoryManager inventoryManager) | ||
59 | { | ||
60 | this._server = server; | ||
61 | this._inventoryManager = inventoryManager; | ||
62 | Textures = new Dictionary<libsecondlife.LLUUID,TextureImage> (); | ||
63 | Assets = new Dictionary<libsecondlife.LLUUID,AssetInfo> (); | ||
64 | this.initialise(); | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// | ||
69 | /// </summary> | ||
70 | private void initialise() | ||
71 | { | ||
72 | //Shape and skin base assets | ||
73 | AssetInfo Asset = new AssetInfo(); | ||
74 | Asset.filename = "base_shape.dat"; | ||
75 | Asset.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); | ||
76 | this.LoadAsset(Asset, false); | ||
77 | this.Assets.Add(Asset.FullID, Asset); | ||
78 | |||
79 | Asset = new AssetInfo(); | ||
80 | Asset.filename = "base_skin.dat"; | ||
81 | Asset.FullID = new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); | ||
82 | this.LoadAsset(Asset, false); | ||
83 | this.Assets.Add(Asset.FullID, Asset); | ||
84 | |||
85 | //our test images | ||
86 | //Change these filenames to images you want to use. | ||
87 | TextureImage Image = new TextureImage(); | ||
88 | Image.filename = "testpic2.jp2"; | ||
89 | Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); | ||
90 | Image.Name = "test Texture"; | ||
91 | this.LoadAsset(Image, true); | ||
92 | this.Textures.Add(Image.FullID, Image); | ||
93 | |||
94 | Image = new TextureImage(); | ||
95 | Image.filename = "map_base.jp2"; | ||
96 | Image.FullID = new LLUUID("00000000-0000-0000-7007-000000000006"); | ||
97 | this.LoadAsset(Image, true); | ||
98 | this.Textures.Add(Image.FullID, Image); | ||
99 | |||
100 | Image = new TextureImage(); | ||
101 | Image.filename = "map1.jp2"; | ||
102 | Image.FullID = new LLUUID("00000000-0000-0000-7009-000000000008"); | ||
103 | this.LoadAsset(Image, true); | ||
104 | this.Textures.Add(Image.FullID, Image); | ||
105 | } | ||
106 | |||
107 | /// <summary> | ||
108 | /// | ||
109 | /// </summary> | ||
110 | /// <param name="UserInfo"></param> | ||
111 | /// <param name="AssetID"></param> | ||
112 | /// <param name="TransferRequest"></param> | ||
113 | #region AssetRegion | ||
114 | |||
115 | public void AddAssetRequest(UserAgentInfo userInfo, LLUUID assetID, TransferRequestPacket transferRequest) | ||
116 | { | ||
117 | |||
118 | if(!this.Assets.ContainsKey(assetID)) | ||
119 | { | ||
120 | //not found asset | ||
121 | return; | ||
122 | } | ||
123 | AssetInfo info = this.Assets[assetID]; | ||
124 | //for now as it will be only skin or shape request just send back the asset | ||
125 | TransferInfoPacket Transfer = new TransferInfoPacket(); | ||
126 | Transfer.TransferInfo.ChannelType = 2; | ||
127 | Transfer.TransferInfo.Status = 0; | ||
128 | Transfer.TransferInfo.TargetType = 0; | ||
129 | Transfer.TransferInfo.Params = transferRequest.TransferInfo.Params; | ||
130 | Transfer.TransferInfo.Size = info.data.Length; | ||
131 | Transfer.TransferInfo.TransferID = transferRequest.TransferInfo.TransferID; | ||
132 | |||
133 | _server.SendPacket(Transfer, true, userInfo); | ||
134 | |||
135 | TransferPacketPacket TransferPacket = new TransferPacketPacket(); | ||
136 | TransferPacket.TransferData.Packet = 0; | ||
137 | TransferPacket.TransferData.ChannelType = 2; | ||
138 | TransferPacket.TransferData.TransferID=transferRequest.TransferInfo.TransferID; | ||
139 | if(info.data.Length>1000) //but needs to be less than 2000 at the moment | ||
140 | { | ||
141 | byte[] chunk = new byte[1000]; | ||
142 | Array.Copy(info.data,chunk,1000); | ||
143 | TransferPacket.TransferData.Data = chunk; | ||
144 | TransferPacket.TransferData.Status = 0; | ||
145 | _server.SendPacket(TransferPacket,true,userInfo); | ||
146 | |||
147 | TransferPacket = new TransferPacketPacket(); | ||
148 | TransferPacket.TransferData.Packet = 1; | ||
149 | TransferPacket.TransferData.ChannelType = 2; | ||
150 | TransferPacket.TransferData.TransferID = transferRequest.TransferInfo.TransferID; | ||
151 | byte[] chunk1 = new byte[(info.data.Length-1000)]; | ||
152 | Array.Copy(info.data, 1000, chunk1, 0, chunk1.Length); | ||
153 | TransferPacket.TransferData.Data = chunk1; | ||
154 | TransferPacket.TransferData.Status = 1; | ||
155 | _server.SendPacket(TransferPacket, true, userInfo); | ||
156 | } | ||
157 | else | ||
158 | { | ||
159 | TransferPacket.TransferData.Status = 1; //last packet? so set to 1 | ||
160 | TransferPacket.TransferData.Data = info.data; | ||
161 | _server.SendPacket(TransferPacket, true, userInfo); | ||
162 | } | ||
163 | |||
164 | } | ||
165 | |||
166 | public void CreateNewInventorySet(ref AvatarData Avata,UserAgentInfo UserInfo) | ||
167 | { | ||
168 | //Create Folders | ||
169 | LLUUID BaseFolder = Avata.BaseFolder; | ||
170 | _inventoryManager.CreateNewFolder(UserInfo, Avata.InventoryFolder); | ||
171 | _inventoryManager.CreateNewFolder(UserInfo, BaseFolder); | ||
172 | |||
173 | //Give a copy of default shape | ||
174 | AssetInfo Base = this.Assets[new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73")]; | ||
175 | AssetInfo Shape = this.CloneAsset(UserInfo.AgentID, Base); | ||
176 | |||
177 | Shape.filename = ""; | ||
178 | Shape.Name = "Default Shape"; | ||
179 | Shape.Description = "Default Shape"; | ||
180 | Shape.InvType = 18; | ||
181 | Shape.Type = libsecondlife.AssetSystem.Asset.ASSET_TYPE_WEARABLE_BODY; | ||
182 | |||
183 | byte[] Agentid = _enc.GetBytes(UserInfo.AgentID.ToStringHyphenated()); | ||
184 | Array.Copy(Agentid, 0, Shape.data, 294, Agentid.Length); | ||
185 | this.Assets.Add(Shape.FullID, Shape); | ||
186 | |||
187 | Avata.Wearables[0].ItemID = _inventoryManager.AddToInventory(UserInfo, BaseFolder, Shape); | ||
188 | Avata.Wearables[0].AssetID = Shape.FullID; | ||
189 | |||
190 | //Give copy of default skin | ||
191 | Base = this.Assets[new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49")]; | ||
192 | AssetInfo Skin=this.CloneAsset(UserInfo.AgentID, Base); | ||
193 | |||
194 | Skin.filename = ""; | ||
195 | Skin.Name = "Default Skin"; | ||
196 | Skin.Description = "Default Skin"; | ||
197 | Skin.InvType = 18; | ||
198 | Skin.Type = libsecondlife.AssetSystem.Asset.ASSET_TYPE_WEARABLE_BODY; | ||
199 | |||
200 | Array.Copy(Agentid,0,Skin.data,238,Agentid.Length); | ||
201 | this.Assets.Add(Skin.FullID, Skin); | ||
202 | |||
203 | Avata.Wearables[1].ItemID = _inventoryManager.AddToInventory(UserInfo, BaseFolder, Skin); | ||
204 | Avata.Wearables[1].AssetID = Skin.FullID; | ||
205 | |||
206 | //give a copy of test texture | ||
207 | TextureImage Texture = this.CloneImage(UserInfo.AgentID, Textures[new LLUUID("00000000-0000-0000-5005-000000000005")]); | ||
208 | this.Textures.Add(Texture.FullID, Texture); | ||
209 | _inventoryManager.AddToInventory(UserInfo, BaseFolder, Texture); | ||
210 | |||
211 | } | ||
212 | |||
213 | |||
214 | private void LoadAsset(AssetBase info, bool Image) | ||
215 | { | ||
216 | //should request Asset from storage manager | ||
217 | //but for now read from file | ||
218 | string folder; | ||
219 | if(Image) | ||
220 | { | ||
221 | folder = @"textures"; | ||
222 | } | ||
223 | else | ||
224 | { | ||
225 | folder = @"assets"; | ||
226 | } | ||
227 | string data_path = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, folder); | ||
228 | string filename = System.IO.Path.Combine(data_path, @info.filename); | ||
229 | FileInfo fInfo = new FileInfo(filename); | ||
230 | |||
231 | long numBytes = fInfo.Length; | ||
232 | |||
233 | FileStream fStream = new FileStream(filename, FileMode.Open, FileAccess.Read); | ||
234 | byte[] idata = new byte[numBytes]; | ||
235 | BinaryReader br = new BinaryReader(fStream); | ||
236 | idata= br.ReadBytes((int)numBytes); | ||
237 | br.Close(); | ||
238 | fStream.Close(); | ||
239 | info.data = idata; | ||
240 | //info.loaded=true; | ||
241 | } | ||
242 | |||
243 | public AssetInfo CloneAsset(LLUUID NewOwner, AssetInfo SourceAsset) | ||
244 | { | ||
245 | AssetInfo NewAsset = new AssetInfo(); | ||
246 | NewAsset.data = new byte[SourceAsset.data.Length]; | ||
247 | Array.Copy(SourceAsset.data, NewAsset.data, SourceAsset.data.Length); | ||
248 | NewAsset.FullID = LLUUID.Random(); | ||
249 | NewAsset.Type = SourceAsset.Type; | ||
250 | NewAsset.InvType = SourceAsset.InvType; | ||
251 | return(NewAsset); | ||
252 | } | ||
253 | #endregion | ||
254 | |||
255 | #region TextureRegion | ||
256 | public void AddTextureRequest(UserAgentInfo userInfo, LLUUID imageID) | ||
257 | { | ||
258 | |||
259 | if(!this.Textures.ContainsKey(imageID)) | ||
260 | { | ||
261 | //not found image so send back image not in data base message | ||
262 | ImageNotInDatabasePacket im_not = new ImageNotInDatabasePacket(); | ||
263 | im_not.ImageID.ID=imageID; | ||
264 | _server.SendPacket(im_not, true, userInfo); | ||
265 | return; | ||
266 | } | ||
267 | TextureImage imag = this.Textures[imageID]; | ||
268 | TextureRequest req = new TextureRequest(); | ||
269 | req.RequestUser = userInfo; | ||
270 | req.RequestImage = imageID; | ||
271 | req.ImageInfo = imag; | ||
272 | |||
273 | if(imag.data.LongLength>600) //should be bigger or smaller? | ||
274 | { | ||
275 | //over 600 bytes so split up file | ||
276 | req.NumPackets = 1 + (int)(imag.data.Length-600+999)/1000; | ||
277 | } | ||
278 | else | ||
279 | { | ||
280 | req.NumPackets = 1; | ||
281 | } | ||
282 | |||
283 | this.TextureRequests.Add(req); | ||
284 | |||
285 | } | ||
286 | |||
287 | public void AddTexture(LLUUID imageID, string name, byte[] data) | ||
288 | { | ||
289 | |||
290 | } | ||
291 | public void DoWork(ulong time) | ||
292 | { | ||
293 | if(this.TextureRequests.Count == 0) | ||
294 | { | ||
295 | //no requests waiting | ||
296 | return; | ||
297 | } | ||
298 | int num; | ||
299 | //should be running in its own thread but for now is called by timer | ||
300 | if(this.TextureRequests.Count < 5) | ||
301 | { | ||
302 | //lower than 5 so do all of them | ||
303 | num = this.TextureRequests.Count; | ||
304 | } | ||
305 | else | ||
306 | { | ||
307 | num=5; | ||
308 | } | ||
309 | TextureRequest req; | ||
310 | for(int i = 0; i < num; i++) | ||
311 | { | ||
312 | req=(TextureRequest)this.TextureRequests[i]; | ||
313 | |||
314 | if(req.PacketCounter == 0) | ||
315 | { | ||
316 | //first time for this request so send imagedata packet | ||
317 | if(req.NumPackets == 1) | ||
318 | { | ||
319 | //only one packet so send whole file | ||
320 | ImageDataPacket im = new ImageDataPacket(); | ||
321 | im.ImageID.Packets = 1; | ||
322 | im.ImageID.ID = req.ImageInfo.FullID; | ||
323 | im.ImageID.Size = (uint)req.ImageInfo.data.Length; | ||
324 | im.ImageData.Data = req.ImageInfo.data; | ||
325 | im.ImageID.Codec = 2; | ||
326 | _server.SendPacket(im, true, req.RequestUser); | ||
327 | req.PacketCounter++; | ||
328 | req.ImageInfo.last_used = time; | ||
329 | //System.Console.WriteLine("sent texture: "+req.image_info.FullID); | ||
330 | } | ||
331 | else | ||
332 | { | ||
333 | //more than one packet so split file up | ||
334 | ImageDataPacket im = new ImageDataPacket(); | ||
335 | im.ImageID.Packets = (ushort)req.NumPackets; | ||
336 | im.ImageID.ID = req.ImageInfo.FullID; | ||
337 | im.ImageID.Size = (uint)req.ImageInfo.data.Length; | ||
338 | im.ImageData.Data = new byte[600]; | ||
339 | Array.Copy(req.ImageInfo.data, 0, im.ImageData.Data, 0, 600); | ||
340 | im.ImageID.Codec = 2; | ||
341 | _server.SendPacket(im, true, req.RequestUser); | ||
342 | req.PacketCounter++; | ||
343 | req.ImageInfo.last_used = time; | ||
344 | //System.Console.WriteLine("sent first packet of texture: | ||
345 | } | ||
346 | } | ||
347 | else | ||
348 | { | ||
349 | //send imagepacket | ||
350 | //more than one packet so split file up | ||
351 | ImagePacketPacket im = new ImagePacketPacket(); | ||
352 | im.ImageID.Packet = (ushort)req.PacketCounter; | ||
353 | im.ImageID.ID = req.ImageInfo.FullID; | ||
354 | int size = req.ImageInfo.data.Length - 600 - 1000*(req.PacketCounter - 1); | ||
355 | if(size > 1000) size = 1000; | ||
356 | im.ImageData.Data = new byte[size]; | ||
357 | Array.Copy(req.ImageInfo.data, 600 + 1000*(req.PacketCounter - 1), im.ImageData.Data, 0, size); | ||
358 | _server.SendPacket(im, true, req.RequestUser); | ||
359 | req.PacketCounter++; | ||
360 | req.ImageInfo.last_used = time; | ||
361 | //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID); | ||
362 | } | ||
363 | } | ||
364 | |||
365 | //remove requests that have been completed | ||
366 | for(int i = 0; i < num; i++) | ||
367 | { | ||
368 | req=(TextureRequest)this.TextureRequests[i]; | ||
369 | if(req.PacketCounter == req.NumPackets) | ||
370 | { | ||
371 | this.TextureRequests.Remove(req); | ||
372 | } | ||
373 | } | ||
374 | } | ||
375 | |||
376 | public void RecieveTexture(Packet pack) | ||
377 | { | ||
378 | |||
379 | } | ||
380 | |||
381 | public TextureImage CloneImage(LLUUID newOwner, TextureImage source) | ||
382 | { | ||
383 | TextureImage newImage = new TextureImage(); | ||
384 | newImage.data = new byte[source.data.Length]; | ||
385 | Array.Copy(source.data,newImage.data,source.data.Length); | ||
386 | newImage.filename = source.filename; | ||
387 | newImage.FullID = LLUUID.Random(); | ||
388 | newImage.Name = source.Name; | ||
389 | return(newImage); | ||
390 | } | ||
391 | |||
392 | #endregion | ||
393 | } | ||
394 | |||
395 | public class AssetRequest | ||
396 | { | ||
397 | public UserAgentInfo RequestUser; | ||
398 | public LLUUID RequestImage; | ||
399 | public AssetInfo asset_inf; | ||
400 | public long data_pointer = 0; | ||
401 | public int num_packets = 0; | ||
402 | public int packet_counter = 0; | ||
403 | |||
404 | public AssetRequest() | ||
405 | { | ||
406 | |||
407 | } | ||
408 | } | ||
409 | public class AssetInfo:AssetBase | ||
410 | { | ||
411 | //public byte[] data; | ||
412 | //public LLUUID Full_ID; | ||
413 | public bool loaded; | ||
414 | public ulong last_used; //need to add a tick/time counter and keep record | ||
415 | // of how often images are requested to unload unused ones. | ||
416 | |||
417 | public AssetInfo() | ||
418 | { | ||
419 | |||
420 | } | ||
421 | } | ||
422 | |||
423 | public class AssetBase | ||
424 | { | ||
425 | public byte[] data; | ||
426 | public LLUUID FullID; | ||
427 | public sbyte Type; | ||
428 | public sbyte InvType; | ||
429 | public string Name; | ||
430 | public string Description; | ||
431 | public string filename; | ||
432 | |||
433 | public AssetBase() | ||
434 | { | ||
435 | |||
436 | } | ||
437 | } | ||
438 | public class TextureRequest | ||
439 | { | ||
440 | public UserAgentInfo RequestUser; | ||
441 | public LLUUID RequestImage; | ||
442 | public TextureImage ImageInfo; | ||
443 | public long DataPointer = 0; | ||
444 | public int NumPackets = 0; | ||
445 | public int PacketCounter = 0; | ||
446 | |||
447 | public TextureRequest() | ||
448 | { | ||
449 | |||
450 | } | ||
451 | } | ||
452 | public class TextureImage: AssetBase | ||
453 | { | ||
454 | //any need for this class now most has been moved into AssetBase? | ||
455 | //public byte[] data; | ||
456 | //public LLUUID Full_ID; | ||
457 | //public string name; | ||
458 | public bool loaded; | ||
459 | public ulong last_used; //need to add a tick/time counter and keep record | ||
460 | // of how often images are requested to unload unused ones. | ||
461 | |||
462 | public TextureImage() | ||
463 | { | ||
464 | |||
465 | } | ||
466 | } | ||
467 | |||
468 | |||
469 | } | ||
diff --git a/Asset_manager.cs b/Asset_manager.cs deleted file mode 100644 index 94832f7..0000000 --- a/Asset_manager.cs +++ /dev/null | |||
@@ -1,231 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://sim.opensecondlife.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 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using libsecondlife; | ||
32 | using System.Collections; | ||
33 | using libsecondlife.Packets; | ||
34 | using libsecondlife.AssetSystem; | ||
35 | using System.IO; | ||
36 | |||
37 | namespace OpenSim | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// Description of Asset_manager. | ||
41 | /// </summary> | ||
42 | public class AssetManager | ||
43 | { | ||
44 | public Dictionary<libsecondlife.LLUUID,AssetInfo> Assets; | ||
45 | public ArrayList requests=new ArrayList(); //should change to a generic | ||
46 | // public ArrayList uploads=new ArrayList(); | ||
47 | private Server server; | ||
48 | public TextureManager TextureMan; | ||
49 | public InventoryManager InventoryManager; | ||
50 | private System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
51 | |||
52 | public AssetManager(Server serve) | ||
53 | { | ||
54 | server=serve; | ||
55 | Assets=new Dictionary<libsecondlife.LLUUID,AssetInfo> (); | ||
56 | this.initialise(); | ||
57 | } | ||
58 | |||
59 | public void AddRequest(User_Agent_info user, LLUUID asset_id, TransferRequestPacket tran_req) | ||
60 | { | ||
61 | Console.WriteLine("Asset Request "+ asset_id); | ||
62 | if(!this.Assets.ContainsKey(asset_id)) | ||
63 | { | ||
64 | //not found asset | ||
65 | return; | ||
66 | } | ||
67 | AssetInfo info=this.Assets[asset_id]; | ||
68 | System.Console.WriteLine("send asset : "+asset_id); | ||
69 | //for now as it will be only skin or shape request just send back the asset | ||
70 | TransferInfoPacket Transfer=new TransferInfoPacket(); | ||
71 | Transfer.TransferInfo.ChannelType=2; | ||
72 | Transfer.TransferInfo.Status=0; | ||
73 | Transfer.TransferInfo.TargetType=0; | ||
74 | Transfer.TransferInfo.Params=tran_req.TransferInfo.Params; | ||
75 | Transfer.TransferInfo.Size=info.data.Length; | ||
76 | Transfer.TransferInfo.TransferID=tran_req.TransferInfo.TransferID; | ||
77 | |||
78 | server.SendPacket(Transfer,true,user); | ||
79 | |||
80 | TransferPacketPacket tran_p=new TransferPacketPacket(); | ||
81 | tran_p.TransferData.Packet=0; | ||
82 | tran_p.TransferData.ChannelType=2; | ||
83 | tran_p.TransferData.TransferID=tran_req.TransferInfo.TransferID; | ||
84 | if(info.data.Length>1000) //but needs to be less than 2000 at the moment | ||
85 | { | ||
86 | byte[] chunk=new byte[1000]; | ||
87 | Array.Copy(info.data,chunk,1000); | ||
88 | tran_p.TransferData.Data=chunk; | ||
89 | tran_p.TransferData.Status=0; | ||
90 | server.SendPacket(tran_p,true,user); | ||
91 | |||
92 | tran_p=new TransferPacketPacket(); | ||
93 | tran_p.TransferData.Packet=1; | ||
94 | tran_p.TransferData.ChannelType=2; | ||
95 | tran_p.TransferData.TransferID=tran_req.TransferInfo.TransferID; | ||
96 | byte[] chunk1=new byte[(info.data.Length-1000)]; | ||
97 | Array.Copy(info.data,1000,chunk1,0,chunk1.Length); | ||
98 | tran_p.TransferData.Data=chunk1; | ||
99 | tran_p.TransferData.Status=1; | ||
100 | server.SendPacket(tran_p,true,user); | ||
101 | } | ||
102 | else | ||
103 | { | ||
104 | tran_p.TransferData.Status=1; //last packet? so set to 1 | ||
105 | tran_p.TransferData.Data=info.data; | ||
106 | server.SendPacket(tran_p,true,user); | ||
107 | } | ||
108 | |||
109 | } | ||
110 | public void CreateNewBaseSet(ref AvatarData Avata,User_Agent_info UserInfo) | ||
111 | { | ||
112 | //LLUUID BaseFolder=new LLUUID("4f5f559e-77a0-a4b9-84f9-8c74c07f7cfc");//*/"4fb2dab6-a987-da66-05ee-96ca82bccbf1"); | ||
113 | //LLUUID BaseFolder=new LLUUID("480e2d92-61f6-9f16-f4f5-0f77cfa4f8f9"); | ||
114 | LLUUID BaseFolder=Avata.BaseFolder; | ||
115 | InventoryManager.CreateNewFolder(UserInfo,Avata.InventoryFolder); | ||
116 | InventoryManager.CreateNewFolder(UserInfo, BaseFolder); | ||
117 | |||
118 | AssetInfo Base=this.Assets[new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73")]; | ||
119 | AssetInfo Shape=new AssetInfo(); | ||
120 | |||
121 | Shape.filename=""; | ||
122 | Shape.data=new byte[Base.data.Length]; | ||
123 | Array.Copy(Base.data,Shape.data,Base.data.Length); | ||
124 | Shape.Full_ID=LLUUID.Random(); | ||
125 | Shape.Name="Default Skin"; | ||
126 | Shape.Description="Default"; | ||
127 | Shape.InvType=18; | ||
128 | |||
129 | Shape.Type=libsecondlife.AssetSystem.Asset.ASSET_TYPE_WEARABLE_BODY; | ||
130 | byte[] Agentid=enc.GetBytes(UserInfo.AgentID.ToStringHyphenated()); | ||
131 | Array.Copy(Agentid,0,Shape.data,294,Agentid.Length); | ||
132 | this.Assets.Add(Shape.Full_ID,Shape); | ||
133 | /*FileStream fStream = new FileStream("Assetshape.dat", FileMode.CreateNew); | ||
134 | BinaryWriter bw = new BinaryWriter(fStream); | ||
135 | bw.Write(Shape.data); | ||
136 | bw.Close(); | ||
137 | fStream.Close();*/ | ||
138 | |||
139 | Avata.Wearables[0].ItemID=InventoryManager.AddToInventory(UserInfo,BaseFolder,Shape); | ||
140 | Avata.Wearables[0].AssetID=Shape.Full_ID; | ||
141 | //Avata.RootFolder=BaseFolder; | ||
142 | |||
143 | //give test texture | ||
144 | |||
145 | TextureImage Texture=TextureMan.textures[new LLUUID("00000000-0000-0000-5005-000000000005")]; | ||
146 | InventoryManager.AddToInventory(UserInfo,BaseFolder,Texture); | ||
147 | |||
148 | } | ||
149 | |||
150 | private void initialise() | ||
151 | { | ||
152 | //for now read in our test image | ||
153 | AssetInfo im=new AssetInfo(); | ||
154 | im.filename="base_shape.dat"; | ||
155 | im.Full_ID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); | ||
156 | this.loadAsset(im); | ||
157 | this.Assets.Add(im.Full_ID,im); | ||
158 | |||
159 | |||
160 | im=new AssetInfo(); | ||
161 | im.filename="base_skin.dat"; | ||
162 | im.Full_ID=new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); | ||
163 | this.loadAsset(im); | ||
164 | this.Assets.Add(im.Full_ID,im); | ||
165 | } | ||
166 | private void loadAsset(AssetInfo info) | ||
167 | { | ||
168 | //should request Asset from storage manager | ||
169 | //but for now read from file | ||
170 | |||
171 | string data_path = System.AppDomain.CurrentDomain.BaseDirectory + @"\assets\"; | ||
172 | string filename=data_path+@info.filename; | ||
173 | FileInfo fInfo = new FileInfo(filename); | ||
174 | |||
175 | long numBytes = fInfo.Length; | ||
176 | |||
177 | FileStream fStream = new FileStream(filename, FileMode.Open, FileAccess.Read); | ||
178 | byte[] idata=new byte[numBytes]; | ||
179 | BinaryReader br = new BinaryReader(fStream); | ||
180 | idata= br.ReadBytes((int)numBytes); | ||
181 | br.Close(); | ||
182 | fStream.Close(); | ||
183 | info.data=idata; | ||
184 | info.loaded=true; | ||
185 | } | ||
186 | } | ||
187 | |||
188 | public class AssetRequest | ||
189 | { | ||
190 | public User_Agent_info RequestUser; | ||
191 | public LLUUID RequestImage; | ||
192 | public AssetInfo asset_inf; | ||
193 | public long data_pointer=0; | ||
194 | public int num_packets=0; | ||
195 | public int packet_counter=0; | ||
196 | |||
197 | public AssetRequest() | ||
198 | { | ||
199 | |||
200 | } | ||
201 | } | ||
202 | public class AssetInfo:AssetBase | ||
203 | { | ||
204 | //public byte[] data; | ||
205 | //public LLUUID Full_ID; | ||
206 | public string filename; | ||
207 | public bool loaded; | ||
208 | public ulong last_used; //need to add a tick/time counter and keep record | ||
209 | // of how often images are requested to unload unused ones. | ||
210 | |||
211 | public AssetInfo() | ||
212 | { | ||
213 | |||
214 | } | ||
215 | } | ||
216 | |||
217 | public class AssetBase | ||
218 | { | ||
219 | public byte[] data; | ||
220 | public LLUUID Full_ID; | ||
221 | public sbyte Type; | ||
222 | public sbyte InvType; | ||
223 | public string Name; | ||
224 | public string Description; | ||
225 | |||
226 | public AssetBase() | ||
227 | { | ||
228 | |||
229 | } | ||
230 | } | ||
231 | } | ||
diff --git a/Controller.cs b/Controller.cs deleted file mode 100644 index d0a17cf..0000000 --- a/Controller.cs +++ /dev/null | |||
@@ -1,358 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://sim.opensecondlife.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.Timers; | ||
32 | using System.Collections.Generic; | ||
33 | using libsecondlife; | ||
34 | using libsecondlife.Packets; | ||
35 | using System.Collections; | ||
36 | using System.Text; | ||
37 | using System.IO; | ||
38 | using Axiom.MathLib; | ||
39 | using log4net; | ||
40 | |||
41 | namespace OpenSim | ||
42 | { | ||
43 | /// <summary> | ||
44 | /// Description of MainForm. | ||
45 | /// </summary> | ||
46 | public partial class Controller : ServerCallback | ||
47 | { | ||
48 | |||
49 | [STAThread] | ||
50 | public static void Main( string[] args ) | ||
51 | { | ||
52 | Controller c = new Controller(); | ||
53 | while( true ) // fuckin' a | ||
54 | System.Threading.Thread.Sleep( 1000 ); | ||
55 | } | ||
56 | |||
57 | private Server _server; | ||
58 | private Logon _login; | ||
59 | private AgentManager _agentManager; | ||
60 | private PrimManager _primManager; | ||
61 | private AssetManagement _assetManager; | ||
62 | private GridManager _gridManager; | ||
63 | private InventoryManager _inventoryManager; | ||
64 | private LoginManager _loginManager; //built in login server | ||
65 | private ulong time; //ticks | ||
66 | private Timer timer1 = new Timer(); | ||
67 | private System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
68 | |||
69 | public Controller() { | ||
70 | _login = new Logon(); // should create a list for these. | ||
71 | _server = new Server( this ); | ||
72 | _agentManager = new AgentManager( this._server ); | ||
73 | _primManager = new PrimManager( this._server ); | ||
74 | _inventoryManager = new InventoryManager(this._server); | ||
75 | _assetManager = new AssetManagement(this._server, _inventoryManager ); | ||
76 | _primManager.AgentManagement = _agentManager; | ||
77 | _agentManager.Prim_Manager = _primManager; | ||
78 | _agentManager.assetManager = _assetManager; | ||
79 | _gridManager = new GridManager(this._server, _agentManager); | ||
80 | |||
81 | if(Globals.Instance.LoginSever) | ||
82 | { | ||
83 | Console.WriteLine("Starting login Server"); | ||
84 | _loginManager = new LoginManager(_login); // startup | ||
85 | _loginManager.Startup(); // login server | ||
86 | } | ||
87 | |||
88 | timer1.Enabled = true; | ||
89 | timer1.Interval = 200; | ||
90 | timer1.Elapsed +=new ElapsedEventHandler( this.Timer1Tick ); | ||
91 | |||
92 | |||
93 | } | ||
94 | public void MainCallback( Packet pack, UserAgentInfo userInfo ) | ||
95 | { | ||
96 | |||
97 | /*if( ( pack.Type != PacketType.StartPingCheck ) && ( pack.Type != PacketType.AgentUpdate ) ) { | ||
98 | //Log packet? | ||
99 | //System.Console.WriteLine(pack.Type); | ||
100 | //this.richTextBox1.Text = this.richTextBox1.Text + "\n " + pack.Type; | ||
101 | }*/ | ||
102 | |||
103 | //should replace with a switch | ||
104 | if( pack.Type == PacketType.AgentSetAppearance ) { | ||
105 | |||
106 | } | ||
107 | else if (pack.Type == PacketType.AgentAnimation) | ||
108 | { | ||
109 | AgentAnimationPacket AgentAni = (AgentAnimationPacket)pack; | ||
110 | for (int i = 0; i < AgentAni.AnimationList.Length; i++) | ||
111 | { | ||
112 | if (AgentAni.AnimationList[i].StartAnim) | ||
113 | { | ||
114 | _agentManager.UpdateAnim(userInfo, AgentAni.AnimationList[0].AnimID, 1); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | } | ||
119 | else if (pack.Type == PacketType.FetchInventory) | ||
120 | { | ||
121 | FetchInventoryPacket FetchInventory = (FetchInventoryPacket)pack; | ||
122 | _inventoryManager.FetchInventory(userInfo, FetchInventory); | ||
123 | } | ||
124 | else if (pack.Type == PacketType.FetchInventoryDescendents) | ||
125 | { | ||
126 | FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)pack; | ||
127 | _inventoryManager.FetchInventoryDescendents(userInfo, Fetch); | ||
128 | } | ||
129 | else if (pack.Type == PacketType.MapBlockRequest) | ||
130 | { | ||
131 | MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)pack; | ||
132 | this._gridManager.RequestMapBlock(userInfo, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); | ||
133 | |||
134 | } | ||
135 | else if (pack.Type == PacketType.UUIDNameRequest) | ||
136 | { | ||
137 | UUIDNameRequestPacket nameRequest = (UUIDNameRequestPacket)pack; | ||
138 | UUIDNameReplyPacket nameReply = new UUIDNameReplyPacket(); | ||
139 | nameReply.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[nameRequest.UUIDNameBlock.Length]; | ||
140 | |||
141 | for (int i = 0; i < nameRequest.UUIDNameBlock.Length; i++) | ||
142 | { | ||
143 | nameReply.UUIDNameBlock[i] = new UUIDNameReplyPacket.UUIDNameBlockBlock(); | ||
144 | nameReply.UUIDNameBlock[i].ID = nameRequest.UUIDNameBlock[i].ID; | ||
145 | nameReply.UUIDNameBlock[i].FirstName = _enc.GetBytes("harry \0"); //for now send any name | ||
146 | nameReply.UUIDNameBlock[i].LastName = _enc.GetBytes("tom \0"); //in future need to look it up | ||
147 | } | ||
148 | |||
149 | _server.SendPacket(nameReply, true, userInfo); | ||
150 | } | ||
151 | else if (pack.Type == PacketType.CloseCircuit) | ||
152 | { | ||
153 | this._agentManager.RemoveAgent(userInfo); | ||
154 | } | ||
155 | else if (pack.Type == PacketType.MapLayerRequest) | ||
156 | { | ||
157 | this._gridManager.RequestMapLayer(userInfo); | ||
158 | } | ||
159 | else if ((pack.Type == PacketType.TeleportRequest) || (pack.Type == PacketType.TeleportLocationRequest)) | ||
160 | { | ||
161 | TeleportLocationRequestPacket Request = (TeleportLocationRequestPacket)pack; | ||
162 | this._gridManager.RequestTeleport(userInfo, Request); | ||
163 | |||
164 | } | ||
165 | else if (pack.Type == PacketType.TransferRequest) | ||
166 | { | ||
167 | TransferRequestPacket transfer = (TransferRequestPacket)pack; | ||
168 | LLUUID id = new LLUUID(transfer.TransferInfo.Params, 0); | ||
169 | _assetManager.AddAssetRequest(userInfo, id, transfer); | ||
170 | } | ||
171 | else if ((pack.Type == PacketType.StartPingCheck)) | ||
172 | { | ||
173 | //reply to pingcheck | ||
174 | libsecondlife.Packets.StartPingCheckPacket startping = (libsecondlife.Packets.StartPingCheckPacket)pack; | ||
175 | libsecondlife.Packets.CompletePingCheckPacket endping = new CompletePingCheckPacket(); | ||
176 | endping.PingID.PingID = startping.PingID.PingID; | ||
177 | _server.SendPacket(endping, true, userInfo); | ||
178 | } | ||
179 | else if (pack.Type == PacketType.CompleteAgentMovement) | ||
180 | { | ||
181 | _agentManager.AgentJoin(userInfo); | ||
182 | } | ||
183 | else if (pack.Type == PacketType.RequestImage) | ||
184 | { | ||
185 | RequestImagePacket imageRequest = (RequestImagePacket)pack; | ||
186 | for (int i = 0; i < imageRequest.RequestImage.Length; i++) | ||
187 | { | ||
188 | this._assetManager.AddTextureRequest(userInfo, imageRequest.RequestImage[i].Image); | ||
189 | } | ||
190 | } | ||
191 | else if (pack.Type == PacketType.RegionHandshakeReply) | ||
192 | { | ||
193 | //recieved regionhandshake so can now start sending info | ||
194 | _agentManager.SendInitialData(userInfo); | ||
195 | } | ||
196 | else if (pack.Type == PacketType.ObjectAdd) | ||
197 | { | ||
198 | ObjectAddPacket ad = (ObjectAddPacket)pack; | ||
199 | _primManager.CreatePrim(userInfo, ad.ObjectData.RayEnd, ad); | ||
200 | } | ||
201 | else if (pack.Type == PacketType.ObjectPosition) | ||
202 | { | ||
203 | //System.Console.WriteLine(pack.ToString()); | ||
204 | } | ||
205 | else if (pack.Type == PacketType.MultipleObjectUpdate) | ||
206 | { | ||
207 | MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)pack; | ||
208 | |||
209 | for (int i = 0; i < multipleupdate.ObjectData.Length; i++) | ||
210 | { | ||
211 | if (multipleupdate.ObjectData[i].Type == 9) //change position | ||
212 | { | ||
213 | libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); | ||
214 | _primManager.UpdatePrimPosition(userInfo, pos, multipleupdate.ObjectData[i].ObjectLocalID, false, libsecondlife.LLQuaternion.Identity); | ||
215 | //should update stored position of the prim | ||
216 | } | ||
217 | else if (multipleupdate.ObjectData[i].Type == 10)//rotation | ||
218 | { | ||
219 | libsecondlife.LLVector3 pos = new LLVector3(100, 100, 22); | ||
220 | libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); | ||
221 | _primManager.UpdatePrimPosition(userInfo, pos, multipleupdate.ObjectData[i].ObjectLocalID, true, rot); | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | else if (pack.Type == PacketType.AgentWearablesRequest) | ||
226 | { | ||
227 | _agentManager.SendIntialAvatarAppearance(userInfo); | ||
228 | } | ||
229 | else if (pack.Type == PacketType.AgentUpdate) | ||
230 | { | ||
231 | // System.Console.WriteLine("agent update"); | ||
232 | AgentUpdatePacket agent = (AgentUpdatePacket)pack; | ||
233 | uint mask = agent.AgentData.ControlFlags & (1); | ||
234 | AvatarData avatar = _agentManager.GetAgent(userInfo.AgentID); | ||
235 | avatar.CameraAtAxis = agent.AgentData.CameraAtAxis; | ||
236 | avatar.CameraUpAxis = agent.AgentData.CameraUpAxis; | ||
237 | avatar.CameraCenter = agent.AgentData.CameraCenter; | ||
238 | avatar.far = agent.AgentData.Far; | ||
239 | |||
240 | if (avatar != null) | ||
241 | { | ||
242 | if (avatar.Started) | ||
243 | { | ||
244 | if (mask == (1)) | ||
245 | { | ||
246 | if (!avatar.Walk) | ||
247 | { | ||
248 | //start walking | ||
249 | _agentManager.SendMoveCommand(userInfo, false, avatar.Position.X, avatar.Position.Y, avatar.Position.Z, 0, agent.AgentData.BodyRotation); | ||
250 | _agentManager.UpdateAnim(avatar.NetInfo, AgentManager.AnimsLLUUID["ANIM_AGENT_WALK"], 1); | ||
251 | Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0); | ||
252 | Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(agent.AgentData.BodyRotation.W, agent.AgentData.BodyRotation.X, agent.AgentData.BodyRotation.Y, agent.AgentData.BodyRotation.Z); | ||
253 | Axiom.MathLib.Vector3 direc = q * v3; | ||
254 | direc.Normalize(); | ||
255 | direc = direc * ((0.03f) * 128f); | ||
256 | |||
257 | avatar.Velocity.X = direc.x; | ||
258 | avatar.Velocity.Y = direc.y; | ||
259 | avatar.Velocity.Z = direc.z; | ||
260 | avatar.Walk = true; | ||
261 | } | ||
262 | } | ||
263 | else | ||
264 | { | ||
265 | if (avatar.Walk) | ||
266 | { | ||
267 | //walking but key not pressed so need to stop | ||
268 | _agentManager.SendMoveCommand(userInfo, true, avatar.Position.X, avatar.Position.Y, avatar.Position.Z, 0, agent.AgentData.BodyRotation); | ||
269 | _agentManager.UpdateAnim(avatar.NetInfo, AgentManager.AnimsLLUUID["ANIM_AGENT_STAND"], 1); | ||
270 | avatar.Walk = false; | ||
271 | avatar.Velocity.X = 0; | ||
272 | avatar.Velocity.Y = 0; | ||
273 | avatar.Velocity.Z = 0; | ||
274 | } | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | else | ||
279 | { | ||
280 | |||
281 | } | ||
282 | } | ||
283 | else if (pack.Type == PacketType.ChatFromViewer) | ||
284 | { | ||
285 | ChatFromViewerPacket chat = (ChatFromViewerPacket)pack; | ||
286 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
287 | |||
288 | string myString = enc.GetString(chat.ChatData.Message); | ||
289 | if (myString != "") | ||
290 | { | ||
291 | string[] comp = new string[10]; | ||
292 | string delimStr = " , "; | ||
293 | char[] delimiter = delimStr.ToCharArray(); | ||
294 | string line; | ||
295 | |||
296 | line = myString; | ||
297 | comp = line.Split(delimiter); | ||
298 | if (comp[0] == "pos") | ||
299 | { | ||
300 | } | ||
301 | else if (comp[0] == "veloc") | ||
302 | { | ||
303 | } | ||
304 | else | ||
305 | { | ||
306 | _agentManager.SendChatMessage(userInfo, line); | ||
307 | } | ||
308 | } | ||
309 | } | ||
310 | } | ||
311 | public void NewUserCallback(UserAgentInfo userInfo ) | ||
312 | { | ||
313 | Console.WriteLine( "new user - {0} - has joined [session {1}]", userInfo.AgentID.ToString(), userInfo.SessionID.ToString() +"curcuit used"+userInfo.circuitCode); | ||
314 | string first,last; | ||
315 | LLUUID Base,Inventory; | ||
316 | lock(_login) | ||
317 | { | ||
318 | first=_login.First; | ||
319 | last=_login.Last; | ||
320 | Base=_login.BaseFolder; | ||
321 | Inventory=_login.InventoryFolder; | ||
322 | //should get agentid and sessionid so they can be checked. | ||
323 | } | ||
324 | _agentManager.NewAgent(userInfo, first, last, Base, Inventory); | ||
325 | //now because of the lack of Global account management (User server etc) | ||
326 | //we need to reset the names back to default incase a teleport happens | ||
327 | //which will not have a Login name set, so they will use default names | ||
328 | lock(_login) | ||
329 | { | ||
330 | _login.First="Test"; | ||
331 | _login.Last="User"; | ||
332 | } | ||
333 | } | ||
334 | |||
335 | public void ErrorCallback( string text ) { | ||
336 | Console.WriteLine( "error report: {0}", text ); | ||
337 | } | ||
338 | |||
339 | void Timer1Tick( object sender, System.EventArgs e ) { | ||
340 | this.time++; | ||
341 | _agentManager.UpdatePositions(); | ||
342 | this._assetManager.DoWork( time ); | ||
343 | } | ||
344 | } | ||
345 | public class Logon | ||
346 | { | ||
347 | public string First = "Test"; | ||
348 | public string Last = "User"; | ||
349 | public LLUUID Agent; | ||
350 | public LLUUID Session; | ||
351 | public LLUUID InventoryFolder; | ||
352 | public LLUUID BaseFolder; | ||
353 | public Logon() | ||
354 | { | ||
355 | |||
356 | } | ||
357 | } | ||
358 | } | ||
diff --git a/Globals.cs b/Globals.cs deleted file mode 100644 index 067893c..0000000 --- a/Globals.cs +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://sim.opensecondlife.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 libsecondlife; | ||
32 | using System.Collections.Generic; | ||
33 | |||
34 | namespace OpenSim | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// Description of Globals. | ||
38 | /// </summary> | ||
39 | public sealed class Globals | ||
40 | { | ||
41 | private static Globals instance = new Globals(); | ||
42 | |||
43 | public static Globals Instance | ||
44 | { | ||
45 | get | ||
46 | { | ||
47 | return instance; | ||
48 | } | ||
49 | } | ||
50 | |||
51 | private Globals() | ||
52 | { | ||
53 | } | ||
54 | |||
55 | public string RegionName = "Test Sandbox\0"; | ||
56 | public ulong RegionHandle = 1096213093147648; | ||
57 | public int IpPort = 1000; | ||
58 | |||
59 | public bool LoginSever = true; | ||
60 | public ushort LoginServerPort = 8080; | ||
61 | |||
62 | |||
63 | |||
64 | |||
65 | } | ||
66 | } | ||
diff --git a/GridManager.cs b/GridManager.cs deleted file mode 100644 index c52bd51..0000000 --- a/GridManager.cs +++ /dev/null | |||
@@ -1,372 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://sim.opensecondlife.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 libsecondlife; | ||
33 | using System.Collections; | ||
34 | using libsecondlife.Packets; | ||
35 | using libsecondlife.AssetSystem; | ||
36 | using System.IO; | ||
37 | using System.Xml; | ||
38 | |||
39 | |||
40 | namespace OpenSim | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// Description of GridManager. | ||
44 | /// </summary> | ||
45 | public class GridManager | ||
46 | { | ||
47 | private Server _server; | ||
48 | private System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
49 | private AgentManager _agentManager; | ||
50 | public Dictionary<ulong,RegionInfo> Grid; | ||
51 | |||
52 | /// <summary> | ||
53 | /// | ||
54 | /// </summary> | ||
55 | /// <param name="serve"></param> | ||
56 | /// <param name="agentManager"></param> | ||
57 | public GridManager(Server server, AgentManager agentManager) | ||
58 | { | ||
59 | Grid = new Dictionary<ulong, RegionInfo>(); | ||
60 | _server = server; | ||
61 | _agentManager = agentManager; | ||
62 | LoadGrid(); | ||
63 | } | ||
64 | |||
65 | /// <summary> | ||
66 | /// | ||
67 | /// </summary> | ||
68 | /// <param name="UserInfo"></param> | ||
69 | public void RequestMapLayer(UserAgentInfo userInfo) | ||
70 | { | ||
71 | //send a layer covering the 800,800 - 1200,1200 area | ||
72 | MapLayerReplyPacket MapReply = new MapLayerReplyPacket(); | ||
73 | MapReply.AgentData.AgentID = userInfo.AgentID; | ||
74 | MapReply.AgentData.Flags = 0; | ||
75 | MapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1]; | ||
76 | MapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock(); | ||
77 | MapReply.LayerData[0].Bottom = 800; | ||
78 | MapReply.LayerData[0].Left = 800; | ||
79 | MapReply.LayerData[0].Top = 1200; | ||
80 | MapReply.LayerData[0].Right = 1200; | ||
81 | MapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-7007-000000000006"); | ||
82 | _server.SendPacket(MapReply, true, userInfo); | ||
83 | } | ||
84 | |||
85 | /// <summary> | ||
86 | /// | ||
87 | /// </summary> | ||
88 | /// <param name="UserInfo"></param> | ||
89 | /// <param name="MinX"></param> | ||
90 | /// <param name="MinY"></param> | ||
91 | /// <param name="MaxX"></param> | ||
92 | /// <param name="MaxY"></param> | ||
93 | public void RequestMapBlock(UserAgentInfo userInfo, int minX, int minY,int maxX,int maxY) | ||
94 | { | ||
95 | foreach (KeyValuePair<ulong, RegionInfo> RegionPair in this.Grid) | ||
96 | { | ||
97 | //check Region is inside the requested area | ||
98 | RegionInfo Region = RegionPair.Value; | ||
99 | if(((Region.X > minX) && (Region.X < maxX)) && ((Region.Y > minY) && (Region.Y < maxY))) | ||
100 | { | ||
101 | MapBlockReplyPacket MapReply = new MapBlockReplyPacket(); | ||
102 | MapReply.AgentData.AgentID = userInfo.AgentID; | ||
103 | MapReply.AgentData.Flags = 0; | ||
104 | MapReply.Data = new MapBlockReplyPacket.DataBlock[1]; | ||
105 | MapReply.Data[0] = new MapBlockReplyPacket.DataBlock(); | ||
106 | MapReply.Data[0].MapImageID = Region.ImageID; | ||
107 | MapReply.Data[0].X = Region.X; | ||
108 | MapReply.Data[0].Y = Region.Y; | ||
109 | MapReply.Data[0].WaterHeight = Region.WaterHeight; | ||
110 | MapReply.Data[0].Name = _enc.GetBytes( Region.Name); | ||
111 | MapReply.Data[0].RegionFlags = 72458694; | ||
112 | MapReply.Data[0].Access = 13; | ||
113 | MapReply.Data[0].Agents = 1; | ||
114 | _server.SendPacket(MapReply, true, userInfo); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | } | ||
119 | |||
120 | /// <summary> | ||
121 | /// | ||
122 | /// </summary> | ||
123 | /// <param name="UserInfo"></param> | ||
124 | /// <param name="Request"></param> | ||
125 | public void RequestTeleport(UserAgentInfo userInfo, TeleportLocationRequestPacket request) | ||
126 | { | ||
127 | if(Grid.ContainsKey(request.Info.RegionHandle)) | ||
128 | { | ||
129 | RegionInfo Region = Grid[request.Info.RegionHandle]; | ||
130 | libsecondlife.Packets.TeleportStartPacket TeleportStart = new TeleportStartPacket(); | ||
131 | TeleportStart.Info.TeleportFlags = 16; | ||
132 | _server.SendPacket(TeleportStart, true, userInfo); | ||
133 | |||
134 | libsecondlife.Packets.TeleportFinishPacket Teleport = new TeleportFinishPacket(); | ||
135 | Teleport.Info.AgentID = userInfo.AgentID; | ||
136 | Teleport.Info.RegionHandle = request.Info.RegionHandle; | ||
137 | Teleport.Info.SimAccess = 13; | ||
138 | Teleport.Info.SeedCapability = new byte[0]; | ||
139 | |||
140 | System.Net.IPAddress oIP = System.Net.IPAddress.Parse(Region.IPAddress.Address); | ||
141 | byte[] byteIP = oIP.GetAddressBytes(); | ||
142 | uint ip=(uint)byteIP[3]<<24; | ||
143 | ip+=(uint)byteIP[2]<<16; | ||
144 | ip+=(uint)byteIP[1]<<8; | ||
145 | ip+=(uint)byteIP[0]; | ||
146 | |||
147 | Teleport.Info.SimIP = ip; | ||
148 | Teleport.Info.SimPort = Region.IPAddress.Port; | ||
149 | Teleport.Info.LocationID = 4; | ||
150 | Teleport.Info.TeleportFlags = 1 << 4;; | ||
151 | _server.SendPacket(Teleport, true, userInfo); | ||
152 | |||
153 | this._agentManager.RemoveAgent(userInfo); | ||
154 | } | ||
155 | |||
156 | } | ||
157 | |||
158 | /// <summary> | ||
159 | /// | ||
160 | /// </summary> | ||
161 | private void LoadGrid() | ||
162 | { | ||
163 | //should connect to a space server to see what grids there are | ||
164 | //but for now we read static xml files | ||
165 | ulong CurrentHandle = 0; | ||
166 | bool Login = true; | ||
167 | |||
168 | XmlDocument doc = new XmlDocument(); | ||
169 | |||
170 | try { | ||
171 | doc.Load(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Grid.ini" )); | ||
172 | } | ||
173 | catch ( Exception e) | ||
174 | { | ||
175 | Console.WriteLine(e.Message); | ||
176 | return; | ||
177 | } | ||
178 | |||
179 | try | ||
180 | { | ||
181 | XmlNode root = doc.FirstChild; | ||
182 | if (root.Name != "Root") | ||
183 | throw new Exception("Error: Invalid File. Missing <Root>"); | ||
184 | |||
185 | XmlNode nodes = root.FirstChild; | ||
186 | if (nodes.Name != "Grid") | ||
187 | throw new Exception("Error: Invalid File. <project> first child should be <Grid>"); | ||
188 | |||
189 | if (nodes.HasChildNodes) { | ||
190 | foreach( XmlNode xmlnc in nodes.ChildNodes) | ||
191 | { | ||
192 | if(xmlnc.Name == "Region") | ||
193 | { | ||
194 | string xmlAttri; | ||
195 | RegionInfo Region = new RegionInfo(); | ||
196 | if(xmlnc.Attributes["Name"] != null) | ||
197 | { | ||
198 | xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Name")).Value; | ||
199 | Region.Name = xmlAttri+" \0"; | ||
200 | } | ||
201 | if(xmlnc.Attributes["ImageID"] != null) | ||
202 | { | ||
203 | xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("ImageID")).Value; | ||
204 | Region.ImageID = new LLUUID(xmlAttri); | ||
205 | } | ||
206 | if(xmlnc.Attributes["IP_Address"] != null) | ||
207 | { | ||
208 | xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("IP_Address")).Value; | ||
209 | Region.IPAddress.Address = xmlAttri; | ||
210 | } | ||
211 | if(xmlnc.Attributes["IP_Port"] != null) | ||
212 | { | ||
213 | xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("IP_Port")).Value; | ||
214 | Region.IPAddress.Port = Convert.ToUInt16(xmlAttri); | ||
215 | } | ||
216 | if(xmlnc.Attributes["Location_X"] != null) | ||
217 | { | ||
218 | xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Location_X")).Value; | ||
219 | Region.X = Convert.ToUInt16(xmlAttri); | ||
220 | } | ||
221 | if(xmlnc.Attributes["Location_Y"] != null) | ||
222 | { | ||
223 | xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Location_Y")).Value; | ||
224 | Region.Y = Convert.ToUInt16(xmlAttri); | ||
225 | } | ||
226 | |||
227 | this.Grid.Add(Region.Handle, Region); | ||
228 | |||
229 | } | ||
230 | if(xmlnc.Name == "CurrentRegion") | ||
231 | { | ||
232 | |||
233 | string xmlAttri; | ||
234 | uint Rx = 0, Ry = 0; | ||
235 | if(xmlnc.Attributes["RegionHandle"] != null) | ||
236 | { | ||
237 | xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("RegionHandle")).Value; | ||
238 | CurrentHandle = Convert.ToUInt64(xmlAttri); | ||
239 | |||
240 | } | ||
241 | else | ||
242 | { | ||
243 | if(xmlnc.Attributes["Region_X"] != null) | ||
244 | { | ||
245 | xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Region_X")).Value; | ||
246 | Rx = Convert.ToUInt32(xmlAttri); | ||
247 | } | ||
248 | if(xmlnc.Attributes["Region_Y"] != null) | ||
249 | { | ||
250 | xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("Region_Y")).Value; | ||
251 | Ry = Convert.ToUInt32(xmlAttri); | ||
252 | } | ||
253 | } | ||
254 | if(xmlnc.Attributes["LoginServer"] != null) | ||
255 | { | ||
256 | xmlAttri = ((XmlAttribute)xmlnc.Attributes.GetNamedItem("LoginServer")).Value; | ||
257 | Login = Convert.ToBoolean(xmlAttri); | ||
258 | |||
259 | } | ||
260 | if(CurrentHandle == 0) | ||
261 | { | ||
262 | //no RegionHandle set | ||
263 | //so check for Region X and Y | ||
264 | if((Rx > 0) && (Ry > 0)) | ||
265 | { | ||
266 | CurrentHandle = Helpers.UIntsToLong((Rx*256), (Ry*256)); | ||
267 | } | ||
268 | else | ||
269 | { | ||
270 | //seems to be no Region location set | ||
271 | // so set default | ||
272 | CurrentHandle = 1096213093147648; | ||
273 | } | ||
274 | } | ||
275 | } | ||
276 | } | ||
277 | |||
278 | //finished loading grid, now set Globals to current region | ||
279 | if(CurrentHandle != 0) | ||
280 | { | ||
281 | if(Grid.ContainsKey(CurrentHandle)) | ||
282 | { | ||
283 | RegionInfo Region = Grid[CurrentHandle]; | ||
284 | Globals.Instance.RegionHandle = Region.Handle; | ||
285 | Globals.Instance.RegionName = Region.Name; | ||
286 | Globals.Instance.IpPort = Region.IPAddress.Port; | ||
287 | Globals.Instance.LoginSever = Login; | ||
288 | } | ||
289 | } | ||
290 | |||
291 | } | ||
292 | } | ||
293 | catch ( Exception e) | ||
294 | { | ||
295 | Console.WriteLine(e.Message); | ||
296 | return; | ||
297 | } | ||
298 | } | ||
299 | } | ||
300 | |||
301 | public class RegionInfo | ||
302 | { | ||
303 | public RegionIP IPAddress; | ||
304 | public string Name; | ||
305 | public ushort x; | ||
306 | public ushort y; | ||
307 | public ulong handle; | ||
308 | public LLUUID ImageID; | ||
309 | public uint Flags; | ||
310 | public byte WaterHeight; | ||
311 | |||
312 | public ushort X | ||
313 | { | ||
314 | get | ||
315 | { | ||
316 | return(x); | ||
317 | } | ||
318 | set | ||
319 | { | ||
320 | x = value; | ||
321 | Handle = Helpers.UIntsToLong((((uint)x)*256), (((uint)y)*256)); | ||
322 | } | ||
323 | } | ||
324 | public ushort Y | ||
325 | { | ||
326 | get | ||
327 | { | ||
328 | return(y); | ||
329 | } | ||
330 | set | ||
331 | { | ||
332 | y = value; | ||
333 | Handle = Helpers.UIntsToLong((((uint)x)*256), (((uint)y)*256)); | ||
334 | } | ||
335 | } | ||
336 | public ulong Handle | ||
337 | { | ||
338 | get | ||
339 | { | ||
340 | if(handle > 0) | ||
341 | { | ||
342 | return(handle); | ||
343 | } | ||
344 | else | ||
345 | { | ||
346 | return(Helpers.UIntsToLong((((uint)x)*256), (((uint)y)*256))); | ||
347 | } | ||
348 | } | ||
349 | set | ||
350 | { | ||
351 | handle = value; | ||
352 | } | ||
353 | |||
354 | } | ||
355 | |||
356 | public RegionInfo() | ||
357 | { | ||
358 | this.IPAddress = new RegionIP(); | ||
359 | } | ||
360 | } | ||
361 | public class RegionIP | ||
362 | { | ||
363 | public string Address; | ||
364 | public ushort Port; | ||
365 | |||
366 | public RegionIP() | ||
367 | { | ||
368 | |||
369 | } | ||
370 | |||
371 | } | ||
372 | } | ||
diff --git a/InventoryManager.cs b/InventoryManager.cs deleted file mode 100644 index 17f7f5c..0000000 --- a/InventoryManager.cs +++ /dev/null | |||
@@ -1,242 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://sim.opensecondlife.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.Generic; | ||
29 | using libsecondlife; | ||
30 | using libsecondlife.Packets; | ||
31 | using libsecondlife.AssetSystem; | ||
32 | using System.IO; | ||
33 | |||
34 | namespace OpenSim | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// Description of InventoryManager. | ||
38 | /// </summary> | ||
39 | public class InventoryManager | ||
40 | { | ||
41 | |||
42 | public Dictionary<LLUUID, InventoryFolder> Folders; | ||
43 | public Dictionary<LLUUID, InventoryItem> Items; | ||
44 | private Server _server; | ||
45 | private System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
46 | private const uint FULL_MASK_PERMISSIONS = 2147483647; | ||
47 | |||
48 | /// <summary> | ||
49 | /// | ||
50 | /// </summary> | ||
51 | /// <param name="serve"></param> | ||
52 | public InventoryManager(Server server) | ||
53 | { | ||
54 | _server = server; | ||
55 | Folders=new Dictionary<LLUUID, InventoryFolder>(); | ||
56 | Items=new Dictionary<LLUUID, InventoryItem>(); | ||
57 | } | ||
58 | |||
59 | /// <summary> | ||
60 | /// | ||
61 | /// </summary> | ||
62 | /// <param name="UserInfo"></param> | ||
63 | /// <param name="FolderID"></param> | ||
64 | /// <param name="Asset"></param> | ||
65 | /// <returns></returns> | ||
66 | public LLUUID AddToInventory(UserAgentInfo userInfo, LLUUID folderID, AssetBase asset) | ||
67 | { | ||
68 | if(this.Folders.ContainsKey(folderID)) | ||
69 | { | ||
70 | LLUUID NewItemID = LLUUID.Random(); | ||
71 | |||
72 | InventoryItem Item = new InventoryItem(); | ||
73 | Item.FolderID = folderID; | ||
74 | Item.OwnerID = userInfo.AgentID; | ||
75 | Item.AssetID = asset.FullID; | ||
76 | Item.ItemID = NewItemID; | ||
77 | Item.Type = asset.Type; | ||
78 | Item.Name = asset.Name; | ||
79 | Item.Description = asset.Description; | ||
80 | Item.InvType = asset.InvType; | ||
81 | this.Items.Add(Item.ItemID, Item); | ||
82 | InventoryFolder Folder = Folders[Item.FolderID]; | ||
83 | Folder.Items.Add(Item); | ||
84 | return(Item.ItemID); | ||
85 | } | ||
86 | else | ||
87 | { | ||
88 | return(null); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | /// <summary> | ||
93 | /// | ||
94 | /// </summary> | ||
95 | /// <param name="UserInfo"></param> | ||
96 | /// <param name="NewFolder"></param> | ||
97 | /// <returns></returns> | ||
98 | public bool CreateNewFolder(UserAgentInfo userInfo, LLUUID newFolder) | ||
99 | { | ||
100 | InventoryFolder Folder = new InventoryFolder(); | ||
101 | Folder.FolderID = newFolder; | ||
102 | Folder.OwnerID = userInfo.AgentID; | ||
103 | this.Folders.Add(Folder.FolderID, Folder); | ||
104 | |||
105 | return(true); | ||
106 | } | ||
107 | |||
108 | /// <summary> | ||
109 | /// | ||
110 | /// </summary> | ||
111 | /// <param name="User_info"></param> | ||
112 | /// <param name="FetchDescend"></param> | ||
113 | public void FetchInventoryDescendents(UserAgentInfo userInfo, FetchInventoryDescendentsPacket FetchDescend) | ||
114 | { | ||
115 | if(FetchDescend.InventoryData.FetchItems) | ||
116 | { | ||
117 | if(this.Folders.ContainsKey(FetchDescend.InventoryData.FolderID)) | ||
118 | { | ||
119 | |||
120 | InventoryFolder Folder = this.Folders[FetchDescend.InventoryData.FolderID]; | ||
121 | InventoryDescendentsPacket Descend = new InventoryDescendentsPacket(); | ||
122 | Descend.AgentData.AgentID = userInfo.AgentID; | ||
123 | Descend.AgentData.OwnerID = Folder.OwnerID; | ||
124 | Descend.AgentData.FolderID = FetchDescend.InventoryData.FolderID; | ||
125 | Descend.AgentData.Descendents = Folder.Items.Count; | ||
126 | Descend.AgentData.Version = Folder.Items.Count; | ||
127 | |||
128 | Descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[Folder.Items.Count]; | ||
129 | for(int i = 0; i < Folder.Items.Count ; i++) | ||
130 | { | ||
131 | |||
132 | InventoryItem Item=Folder.Items[i]; | ||
133 | Descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); | ||
134 | Descend.ItemData[i].ItemID = Item.ItemID; | ||
135 | Descend.ItemData[i].AssetID = Item.AssetID; | ||
136 | Descend.ItemData[i].CreatorID = Item.CreatorID; | ||
137 | Descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS; | ||
138 | Descend.ItemData[i].CreationDate = 1000; | ||
139 | Descend.ItemData[i].Description = _enc.GetBytes(Item.Description+"\0"); | ||
140 | Descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS; | ||
141 | Descend.ItemData[i].Flags = 1; | ||
142 | Descend.ItemData[i].FolderID = Item.FolderID; | ||
143 | Descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
144 | Descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS; | ||
145 | Descend.ItemData[i].InvType = Item.InvType; | ||
146 | Descend.ItemData[i].Name = _enc.GetBytes(Item.Name+"\0"); | ||
147 | Descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS; | ||
148 | Descend.ItemData[i].OwnerID = Item.OwnerID; | ||
149 | Descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS; | ||
150 | Descend.ItemData[i].SalePrice = 100; | ||
151 | Descend.ItemData[i].SaleType = 0; | ||
152 | Descend.ItemData[i].Type = Item.Type; | ||
153 | Descend.ItemData[i].CRC=libsecondlife.Helpers.InventoryCRC(1000, 0, Descend.ItemData[i].InvType, Descend.ItemData[i].Type, Descend.ItemData[i].AssetID, Descend.ItemData[i].GroupID, 100, Descend.ItemData[i].OwnerID, Descend.ItemData[i].CreatorID, Descend.ItemData[i].ItemID, Descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); | ||
154 | } | ||
155 | _server.SendPacket(Descend, true, userInfo); | ||
156 | |||
157 | } | ||
158 | } | ||
159 | else | ||
160 | { | ||
161 | Console.WriteLine("fetch subfolders"); | ||
162 | } | ||
163 | } | ||
164 | |||
165 | /// <summary> | ||
166 | /// | ||
167 | /// </summary> | ||
168 | /// <param name="User_info"></param> | ||
169 | public void FetchInventory(UserAgentInfo userInfo, FetchInventoryPacket FetchItems) | ||
170 | { | ||
171 | |||
172 | for(int i = 0; i < FetchItems.InventoryData.Length; i++) | ||
173 | { | ||
174 | if(this.Items.ContainsKey(FetchItems.InventoryData[i].ItemID)) | ||
175 | { | ||
176 | |||
177 | InventoryItem Item = Items[FetchItems.InventoryData[i].ItemID]; | ||
178 | FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket(); | ||
179 | InventoryReply.AgentData.AgentID = userInfo.AgentID; | ||
180 | InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; | ||
181 | InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); | ||
182 | InventoryReply.InventoryData[0].ItemID = Item.ItemID; | ||
183 | InventoryReply.InventoryData[0].AssetID = Item.AssetID; | ||
184 | InventoryReply.InventoryData[0].CreatorID = Item.CreatorID; | ||
185 | InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; | ||
186 | InventoryReply.InventoryData[0].CreationDate = 1000; | ||
187 | InventoryReply.InventoryData[0].Description = _enc.GetBytes( Item.Description+"\0"); | ||
188 | InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; | ||
189 | InventoryReply.InventoryData[0].Flags = 1; | ||
190 | InventoryReply.InventoryData[0].FolderID = Item.FolderID; | ||
191 | InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
192 | InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; | ||
193 | InventoryReply.InventoryData[0].InvType = Item.InvType; | ||
194 | InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name+"\0"); | ||
195 | InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; | ||
196 | InventoryReply.InventoryData[0].OwnerID = Item.OwnerID; | ||
197 | InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; | ||
198 | InventoryReply.InventoryData[0].SalePrice = 100; | ||
199 | InventoryReply.InventoryData[0].SaleType = 0; | ||
200 | InventoryReply.InventoryData[0].Type = Item.Type; | ||
201 | InventoryReply.InventoryData[0].CRC = libsecondlife.Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); | ||
202 | _server.SendPacket(InventoryReply, true, userInfo); | ||
203 | } | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | |||
208 | public class InventoryFolder | ||
209 | { | ||
210 | public List<InventoryItem> Items; | ||
211 | //public List<InventoryFolder> Subfolders; | ||
212 | |||
213 | public LLUUID FolderID; | ||
214 | public LLUUID OwnerID; | ||
215 | public LLUUID ParentID; | ||
216 | |||
217 | |||
218 | public InventoryFolder() | ||
219 | { | ||
220 | Items = new List<InventoryItem>(); | ||
221 | } | ||
222 | |||
223 | } | ||
224 | |||
225 | public class InventoryItem | ||
226 | { | ||
227 | public LLUUID FolderID; | ||
228 | public LLUUID OwnerID; | ||
229 | public LLUUID ItemID; | ||
230 | public LLUUID AssetID; | ||
231 | public LLUUID CreatorID = LLUUID.Zero; | ||
232 | public sbyte InvType; | ||
233 | public sbyte Type; | ||
234 | public string Name; | ||
235 | public string Description; | ||
236 | |||
237 | public InventoryItem() | ||
238 | { | ||
239 | |||
240 | } | ||
241 | } | ||
242 | } | ||
diff --git a/Login_manager.cs b/Login_manager.cs deleted file mode 100644 index 2d4f524..0000000 --- a/Login_manager.cs +++ /dev/null | |||
@@ -1,228 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/> | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the <organization> nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using Nwc.XmlRpc; | ||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Net; | ||
31 | using System.Net.Sockets; | ||
32 | using System.Text; | ||
33 | using System.Text.RegularExpressions; | ||
34 | using System.Threading; | ||
35 | using System.Collections; | ||
36 | using System.Xml; | ||
37 | using libsecondlife; | ||
38 | |||
39 | namespace OpenSim | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// Description of Login_manager. | ||
43 | /// </summary> | ||
44 | public class LoginManager | ||
45 | { | ||
46 | public LoginManager(Logon login) | ||
47 | { | ||
48 | Login=login; | ||
49 | } | ||
50 | public Logon Login; | ||
51 | public ushort loginPort = Globals.Instance.LoginServerPort; | ||
52 | public IPAddress clientAddress = IPAddress.Loopback; | ||
53 | public IPAddress remoteAddress = IPAddress.Any; | ||
54 | private Socket loginServer; | ||
55 | private Random RandomClass = new Random(); | ||
56 | private int NumClients; | ||
57 | |||
58 | // InitializeLoginProxy: initialize the login proxy | ||
59 | private void InitializeLoginProxy() { | ||
60 | loginServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); | ||
61 | loginServer.Bind(new IPEndPoint(remoteAddress, loginPort)); | ||
62 | loginServer.Listen(1); | ||
63 | } | ||
64 | |||
65 | public void Startup() | ||
66 | { | ||
67 | this.InitializeLoginProxy(); | ||
68 | Thread runLoginProxy = new Thread(new ThreadStart(RunLoginProxy)); | ||
69 | runLoginProxy.IsBackground = true; | ||
70 | runLoginProxy.Start(); | ||
71 | } | ||
72 | |||
73 | private void RunLoginProxy() | ||
74 | { | ||
75 | try | ||
76 | { | ||
77 | for (;;) | ||
78 | { | ||
79 | Socket client = loginServer.Accept(); | ||
80 | IPEndPoint clientEndPoint = (IPEndPoint)client.RemoteEndPoint; | ||
81 | |||
82 | |||
83 | NetworkStream networkStream = new NetworkStream(client); | ||
84 | StreamReader networkReader = new StreamReader(networkStream); | ||
85 | StreamWriter networkWriter = new StreamWriter(networkStream); | ||
86 | |||
87 | try | ||
88 | { | ||
89 | ProxyLogin(networkReader, networkWriter); | ||
90 | } | ||
91 | catch (Exception e) | ||
92 | { | ||
93 | Console.WriteLine(e.Message); | ||
94 | } | ||
95 | |||
96 | networkWriter.Close(); | ||
97 | networkReader.Close(); | ||
98 | networkStream.Close(); | ||
99 | |||
100 | client.Close(); | ||
101 | |||
102 | // send any packets queued for injection | ||
103 | |||
104 | } | ||
105 | } | ||
106 | catch (Exception e) | ||
107 | { | ||
108 | Console.WriteLine(e.Message); | ||
109 | Console.WriteLine(e.StackTrace); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | // ProxyLogin: proxy a login request | ||
114 | private void ProxyLogin(StreamReader reader, StreamWriter writer) { lock(this) { | ||
115 | string line; | ||
116 | int contentLength = 0; | ||
117 | |||
118 | // read HTTP header | ||
119 | do | ||
120 | { | ||
121 | // read one line of the header | ||
122 | line = reader.ReadLine(); | ||
123 | |||
124 | // check for premature EOF | ||
125 | if (line == null) | ||
126 | throw new Exception("EOF in client HTTP header"); | ||
127 | |||
128 | // look for Content-Length | ||
129 | Match match = (new Regex(@"Content-Length: (\d+)$")).Match(line); | ||
130 | if (match.Success) | ||
131 | contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString()); | ||
132 | } while (line != ""); | ||
133 | |||
134 | // read the HTTP body into a buffer | ||
135 | char[] content = new char[contentLength]; | ||
136 | reader.Read(content, 0, contentLength); | ||
137 | //System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
138 | XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content)); | ||
139 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
140 | |||
141 | string first; | ||
142 | string last; | ||
143 | LLUUID Agent; | ||
144 | LLUUID Session; | ||
145 | |||
146 | //get login name | ||
147 | if(requestData.Contains("first")) | ||
148 | { | ||
149 | first = (string)requestData["first"]; | ||
150 | } | ||
151 | else | ||
152 | { | ||
153 | first = "test"; | ||
154 | } | ||
155 | if(requestData.Contains("last")) | ||
156 | { | ||
157 | last = (string)requestData["last"]; | ||
158 | } | ||
159 | else | ||
160 | { | ||
161 | last = "User"+NumClients.ToString(); | ||
162 | } | ||
163 | NumClients++; | ||
164 | |||
165 | //create a agent and session LLUUID | ||
166 | int AgentRand = this.RandomClass.Next(1,9999); | ||
167 | Agent = new LLUUID("99998888-"+AgentRand.ToString("0000")+"-4f52-8ec1-0b1d5cd6aead"); | ||
168 | int SessionRand = this.RandomClass.Next(1,999); | ||
169 | Session = new LLUUID("aaaabbbb-8932-"+SessionRand.ToString("0000")+"-8664-58f53e442797"); | ||
170 | |||
171 | |||
172 | StreamReader SR; | ||
173 | string ResponseString = ""; | ||
174 | string lines; | ||
175 | SR=File.OpenText("new-login.dat"); | ||
176 | |||
177 | lines=SR.ReadLine(); | ||
178 | |||
179 | while(lines != "end-mfile") | ||
180 | { | ||
181 | |||
182 | ResponseString += lines; | ||
183 | lines = SR.ReadLine(); | ||
184 | } | ||
185 | SR.Close(); | ||
186 | |||
187 | XmlRpcResponse response =(XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(ResponseString); | ||
188 | Hashtable responseData = (Hashtable)response.Value; | ||
189 | |||
190 | responseData["agent_id"] = Agent.ToStringHyphenated(); | ||
191 | responseData["session_id"] = Session.ToStringHyphenated(); | ||
192 | ArrayList InventoryList = (ArrayList) responseData["inventory-skeleton"]; | ||
193 | Hashtable Inventory1 = (Hashtable)InventoryList[0]; | ||
194 | Hashtable Inventory2 = (Hashtable)InventoryList[1]; | ||
195 | LLUUID BaseFolderID = LLUUID.Random(); | ||
196 | LLUUID InventoryFolderID = LLUUID.Random(); | ||
197 | Inventory2["name"] = "Base"; | ||
198 | Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated(); | ||
199 | Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated(); | ||
200 | |||
201 | ArrayList InventoryRoot = (ArrayList) responseData["inventory-root"]; | ||
202 | Hashtable Inventoryroot = (Hashtable)InventoryRoot[0]; | ||
203 | Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated(); | ||
204 | |||
205 | |||
206 | //copy data to login object | ||
207 | lock(Login) | ||
208 | { | ||
209 | Login.First = first; | ||
210 | Login.Last = last; | ||
211 | Login.Agent = Agent; | ||
212 | Login.Session = Session; | ||
213 | Login.BaseFolder = BaseFolderID; | ||
214 | Login.InventoryFolder = InventoryFolderID; | ||
215 | } | ||
216 | |||
217 | // forward the XML-RPC response to the client | ||
218 | writer.WriteLine("HTTP/1.0 200 OK"); | ||
219 | writer.WriteLine("Content-type: text/xml"); | ||
220 | writer.WriteLine(); | ||
221 | |||
222 | XmlTextWriter responseWriter = new XmlTextWriter(writer); | ||
223 | XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response); | ||
224 | responseWriter.Close(); | ||
225 | } | ||
226 | } | ||
227 | } | ||
228 | } | ||
diff --git a/Physics_manager.cs b/Physics_manager.cs deleted file mode 100644 index 17f3340..0000000 --- a/Physics_manager.cs +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the <organization> nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | |||
30 | namespace OpenSim | ||
31 | { | ||
32 | /// <summary> | ||
33 | /// Description of Physics_manager. | ||
34 | /// </summary> | ||
35 | public class PhysicsManager | ||
36 | { | ||
37 | public PhysicsManager() | ||
38 | { | ||
39 | } | ||
40 | } | ||
41 | } | ||
diff --git a/Prim_manager.cs b/Prim_manager.cs deleted file mode 100644 index 3b6af10..0000000 --- a/Prim_manager.cs +++ /dev/null | |||
@@ -1,382 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the <organization> nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using libsecondlife; | ||
31 | using libsecondlife.Packets; | ||
32 | using libsecondlife.AssetSystem; | ||
33 | using System.IO; | ||
34 | using Axiom.MathLib; | ||
35 | |||
36 | namespace OpenSim | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Description of Prim_manager. | ||
40 | /// </summary> | ||
41 | public class PrimManager | ||
42 | { | ||
43 | private Server _server; | ||
44 | private uint _primCount; | ||
45 | |||
46 | public AgentManager AgentManagement; | ||
47 | public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock PrimTemplate; | ||
48 | public Dictionary<libsecondlife.LLUUID,PrimInfo> PrimList; | ||
49 | |||
50 | /// <summary> | ||
51 | /// | ||
52 | /// </summary> | ||
53 | /// <param name="serve"></param> | ||
54 | public PrimManager(Server server) | ||
55 | { | ||
56 | _server = server; | ||
57 | PrimList = new Dictionary<libsecondlife.LLUUID,PrimInfo> (); | ||
58 | this.SetupTemplates("objectupate164.dat"); | ||
59 | |||
60 | } | ||
61 | |||
62 | /// <summary> | ||
63 | /// | ||
64 | /// </summary> | ||
65 | /// <param name="User_info"></param> | ||
66 | /// <param name="p1"></param> | ||
67 | /// <param name="add_pack"></param> | ||
68 | public void CreatePrim(UserAgentInfo userInfo, libsecondlife.LLVector3 pos1, ObjectAddPacket addPacket) | ||
69 | { | ||
70 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
71 | objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle; | ||
72 | objupdate.RegionData.TimeDilation = 64096; | ||
73 | |||
74 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
75 | PrimData PData = new PrimData(); | ||
76 | objupdate.ObjectData[0] = this.PrimTemplate; | ||
77 | PData.OwnerID=objupdate.ObjectData[0].OwnerID = userInfo.AgentID; | ||
78 | PData.PCode=objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode; | ||
79 | PData.PathBegin=objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin; | ||
80 | PData.PathEnd=objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd; | ||
81 | PData.PathScaleX=objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX; | ||
82 | PData.PathScaleY=objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY; | ||
83 | PData.PathShearX=objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX; | ||
84 | PData.PathShearY=objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY; | ||
85 | PData.PathSkew=objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew; | ||
86 | PData.ProfileBegin=objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin; | ||
87 | PData.ProfileEnd=objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd; | ||
88 | PData.Scale=objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale; | ||
89 | PData.PathCurve=objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve; | ||
90 | PData.ProfileCurve=objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve; | ||
91 | PData.ParentID=objupdate.ObjectData[0].ParentID = 0; | ||
92 | PData.ProfileHollow=objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow; | ||
93 | //finish off copying rest of shape data | ||
94 | |||
95 | objupdate.ObjectData[0].ID = (uint)(702000 + _primCount); | ||
96 | objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efefda"+_primCount.ToString("000")); | ||
97 | |||
98 | //update position | ||
99 | byte[] pb = pos1.GetBytes(); | ||
100 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length); | ||
101 | |||
102 | _primCount++; | ||
103 | _server.SendPacket(objupdate, true, userInfo); | ||
104 | |||
105 | //should send to all users | ||
106 | foreach (KeyValuePair<libsecondlife.LLUUID, AvatarData> kp in AgentManagement.AgentList) | ||
107 | { | ||
108 | if(kp.Value.NetInfo.AgentID != userInfo.AgentID) | ||
109 | { | ||
110 | _server.SendPacket(objupdate, true, kp.Value.NetInfo); | ||
111 | } | ||
112 | } | ||
113 | //should store this infomation | ||
114 | PrimInfo NewPrim = new PrimInfo(); | ||
115 | NewPrim.FullID = objupdate.ObjectData[0].FullID; | ||
116 | NewPrim.LocalID = objupdate.ObjectData[0].ID; | ||
117 | NewPrim.Position = pos1; | ||
118 | NewPrim.Data = PData; | ||
119 | |||
120 | this.PrimList.Add(NewPrim.FullID, NewPrim); | ||
121 | |||
122 | //store rest of data | ||
123 | |||
124 | } | ||
125 | |||
126 | /// <summary> | ||
127 | /// | ||
128 | /// </summary> | ||
129 | /// <param name="User"></param> | ||
130 | /// <param name="position"></param> | ||
131 | /// <param name="LocalID"></param> | ||
132 | /// <param name="setRotation"></param> | ||
133 | /// <param name="rotation"></param> | ||
134 | public void UpdatePrimPosition(UserAgentInfo userInfo, LLVector3 position, uint localID, bool setRotation, LLQuaternion rotation) | ||
135 | { | ||
136 | PrimInfo pri = null; | ||
137 | foreach (KeyValuePair<libsecondlife.LLUUID,PrimInfo> kp in this.PrimList) | ||
138 | { | ||
139 | if(kp.Value.LocalID == localID) | ||
140 | { | ||
141 | pri = kp.Value; | ||
142 | } | ||
143 | } | ||
144 | if(pri == null) | ||
145 | { | ||
146 | return; | ||
147 | } | ||
148 | uint ID = pri.LocalID; | ||
149 | libsecondlife.LLVector3 pos2 = new LLVector3(position.X, position.Y, position.Z); | ||
150 | libsecondlife.LLQuaternion rotation2; | ||
151 | if(!setRotation) | ||
152 | { | ||
153 | pri.Position = pos2; | ||
154 | rotation2 = new LLQuaternion(pri.Rotation.X, pri.Rotation.Y, pri.Rotation.Z, pri.Rotation.W); | ||
155 | } | ||
156 | else | ||
157 | { | ||
158 | rotation2=new LLQuaternion(rotation.X, rotation.Y, rotation.Z, rotation.W); | ||
159 | pos2 = pri.Position; | ||
160 | pri.Rotation = rotation; | ||
161 | } | ||
162 | rotation2.W += 1; | ||
163 | rotation2.X += 1; | ||
164 | rotation2.Y += 1; | ||
165 | rotation2.Z += 1; | ||
166 | |||
167 | byte[] bytes = new byte[60]; | ||
168 | |||
169 | ImprovedTerseObjectUpdatePacket im = new ImprovedTerseObjectUpdatePacket(); | ||
170 | im.RegionData.RegionHandle = Globals.Instance.RegionHandle; | ||
171 | im.RegionData.TimeDilation = 64096; | ||
172 | im.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
173 | int i = 0; | ||
174 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | ||
175 | im.ObjectData[0] = dat; | ||
176 | dat.TextureEntry = PrimTemplate.TextureEntry; | ||
177 | |||
178 | bytes[i++] = (byte)(ID % 256); | ||
179 | bytes[i++] = (byte)((ID >> 8) % 256); | ||
180 | bytes[i++] = (byte)((ID >> 16) % 256); | ||
181 | bytes[i++] = (byte)((ID >> 24) % 256); | ||
182 | bytes[i++]= 0; | ||
183 | bytes[i++]= 0; | ||
184 | |||
185 | byte[] pb = pos2.GetBytes(); | ||
186 | pri.Position = pos2; | ||
187 | Array.Copy(pb, 0, bytes, i, pb.Length); | ||
188 | i += 12; | ||
189 | ushort ac = 32767; | ||
190 | |||
191 | //vel | ||
192 | bytes[i++] = (byte)(ac % 256); | ||
193 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
194 | bytes[i++] = (byte)(ac % 256); | ||
195 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
196 | bytes[i++] = (byte)(ac % 256); | ||
197 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
198 | |||
199 | //accel | ||
200 | bytes[i++] = (byte)(ac % 256); | ||
201 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
202 | bytes[i++] = (byte)(ac % 256); | ||
203 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
204 | bytes[i++] = (byte)(ac % 256); | ||
205 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
206 | |||
207 | ushort rw, rx,ry,rz; | ||
208 | rw = (ushort)(32768 * rotation2.W); | ||
209 | rx = (ushort)(32768 * rotation2.X); | ||
210 | ry = (ushort)(32768 * rotation2.Y); | ||
211 | rz = (ushort)(32768 * rotation2.Z); | ||
212 | |||
213 | //rot | ||
214 | bytes[i++] = (byte)(rx % 256); | ||
215 | bytes[i++] = (byte)((rx >> 8) % 256); | ||
216 | bytes[i++] = (byte)(ry % 256); | ||
217 | bytes[i++] = (byte)((ry >> 8) % 256); | ||
218 | bytes[i++] = (byte)(rz % 256); | ||
219 | bytes[i++] = (byte)((rz >> 8) % 256); | ||
220 | bytes[i++] = (byte)(rw % 256); | ||
221 | bytes[i++] = (byte)((rw >> 8) % 256); | ||
222 | |||
223 | //rotation vel | ||
224 | bytes[i++] = (byte)(ac % 256); | ||
225 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
226 | bytes[i++] = (byte)(ac % 256); | ||
227 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
228 | bytes[i++] = (byte)(ac % 256); | ||
229 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
230 | |||
231 | dat.Data=bytes; | ||
232 | |||
233 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in AgentManagement.AgentList) | ||
234 | { | ||
235 | if(kp.Value.NetInfo.AgentID!=userInfo.AgentID) | ||
236 | { | ||
237 | _server.SendPacket(im, true, kp.Value.NetInfo); | ||
238 | } | ||
239 | } | ||
240 | } | ||
241 | |||
242 | /// <summary> | ||
243 | /// | ||
244 | /// </summary> | ||
245 | /// <param name="user"></param> | ||
246 | public void SendExistingPrims(UserAgentInfo userInfo) | ||
247 | { | ||
248 | //send data for already created prims to a new joining user | ||
249 | } | ||
250 | |||
251 | /// <summary> | ||
252 | /// | ||
253 | /// </summary> | ||
254 | /// <param name="name"></param> | ||
255 | public void SetupTemplates(string name) | ||
256 | { | ||
257 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
258 | objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle; | ||
259 | objupdate.RegionData.TimeDilation = 64096; | ||
260 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
261 | |||
262 | int i = 0; | ||
263 | FileInfo fInfo = new FileInfo(name); | ||
264 | long numBytes = fInfo.Length; | ||
265 | FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); | ||
266 | BinaryReader br = new BinaryReader(fStream); | ||
267 | byte [] data1 = br.ReadBytes((int)numBytes); | ||
268 | br.Close(); | ||
269 | fStream.Close(); | ||
270 | |||
271 | libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i); | ||
272 | objupdate.ObjectData[0] = objdata; | ||
273 | this.PrimTemplate = objdata; | ||
274 | objdata.UpdateFlags = objdata.UpdateFlags + 12 - 16 + 32 + 256; | ||
275 | objdata.OwnerID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
276 | //test adding a new texture to object , to test image downloading | ||
277 | LLObject.TextureEntry te = new LLObject.TextureEntry(objdata.TextureEntry, 0, objdata.TextureEntry.Length); | ||
278 | te.DefaultTexture.TextureID = new LLUUID("00000000-0000-0000-5005-000000000005"); | ||
279 | |||
280 | LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); | ||
281 | |||
282 | objdata.TextureEntry = ntex.ToBytes(); | ||
283 | } | ||
284 | |||
285 | /// <summary> | ||
286 | /// | ||
287 | /// </summary> | ||
288 | /// <param name="name"></param> | ||
289 | /// <param name="user"></param> | ||
290 | public void ReadPrimDatabase(string name, UserAgentInfo userInfo) | ||
291 | { | ||
292 | StreamReader SR; | ||
293 | string line; | ||
294 | SR=File.OpenText(name); | ||
295 | string [] comp = new string[10]; | ||
296 | string delimStr = " , "; | ||
297 | char [] delimiter = delimStr.ToCharArray(); | ||
298 | |||
299 | line=SR.ReadLine(); | ||
300 | while(line != "end") | ||
301 | { | ||
302 | comp = line.Split(delimiter); | ||
303 | if(comp[0] == "ObjPack") | ||
304 | { | ||
305 | int num = Convert.ToInt32(comp[2]); | ||
306 | int start = Convert.ToInt32(comp[1]); | ||
307 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
308 | objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle; | ||
309 | objupdate.RegionData.TimeDilation = 64096; | ||
310 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[num]; | ||
311 | |||
312 | // int count=0; | ||
313 | string data_path = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, @"data"); | ||
314 | for(int cc = 0; cc < num; cc++) | ||
315 | { | ||
316 | string filenam = System.IO.Path.Combine(data_path, @"prim_updates"+start+".dat"); | ||
317 | int i = 0; | ||
318 | //FileInfo fInfo = new FileInfo("objectupate"+start+".dat"); | ||
319 | FileInfo fInfo = new FileInfo(filenam); | ||
320 | long numBytes = fInfo.Length; | ||
321 | //FileStream fStream = new FileStream("objectupate"+start+".dat", FileMode.Open, FileAccess.Read); | ||
322 | FileStream fStream = new FileStream(filenam, FileMode.Open, FileAccess.Read); | ||
323 | BinaryReader br = new BinaryReader(fStream); | ||
324 | byte [] data1 = br.ReadBytes((int)numBytes); | ||
325 | br.Close(); | ||
326 | fStream.Close(); | ||
327 | |||
328 | libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); | ||
329 | objupdate.ObjectData[cc] = objdata; | ||
330 | start++; | ||
331 | } | ||
332 | _server.SendPacket(objupdate, true, userInfo); | ||
333 | line = SR.ReadLine(); | ||
334 | } | ||
335 | } | ||
336 | SR.Close(); | ||
337 | } | ||
338 | } | ||
339 | |||
340 | public class PrimInfo | ||
341 | { | ||
342 | public LLVector3 Position; | ||
343 | public LLVector3 Velocity; | ||
344 | public LLQuaternion Rotation=LLQuaternion.Identity; | ||
345 | public uint LocalID; | ||
346 | public LLUUID FullID; | ||
347 | public PrimData Data; | ||
348 | |||
349 | public PrimInfo() | ||
350 | { | ||
351 | Position=new LLVector3(0,0,0); | ||
352 | Velocity=new LLVector3(0,0,0); | ||
353 | //data=new PrimData(); | ||
354 | } | ||
355 | } | ||
356 | public class PrimData | ||
357 | { | ||
358 | public LLUUID OwnerID; | ||
359 | public byte PCode; | ||
360 | public byte PathBegin; | ||
361 | public byte PathEnd; | ||
362 | public byte PathScaleX; | ||
363 | public byte PathScaleY; | ||
364 | public byte PathShearX; | ||
365 | public byte PathShearY; | ||
366 | public sbyte PathSkew; | ||
367 | public byte ProfileBegin; | ||
368 | public byte ProfileEnd; | ||
369 | public LLVector3 Scale; | ||
370 | public byte PathCurve; | ||
371 | public byte ProfileCurve; | ||
372 | public uint ParentID=0; | ||
373 | public byte ProfileHollow; | ||
374 | |||
375 | public bool DataBaseStorage=false; | ||
376 | |||
377 | public PrimData() | ||
378 | { | ||
379 | |||
380 | } | ||
381 | } | ||
382 | } | ||
diff --git a/SceneGraphManager.cs b/SceneGraphManager.cs deleted file mode 100644 index 739eccb..0000000 --- a/SceneGraphManager.cs +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://sim.opensecondlife.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 | /// Description of SceneGraphManager. | ||
33 | /// </summary> | ||
34 | public class SceneGraphManager | ||
35 | { | ||
36 | public SceneGraphManager() | ||
37 | { | ||
38 | } | ||
39 | } | ||
40 | } | ||
diff --git a/Script_manager.cs b/Script_manager.cs deleted file mode 100644 index 26b87f1..0000000 --- a/Script_manager.cs +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the <organization> nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | |||
27 | */ | ||
28 | |||
29 | using System; | ||
30 | using System.Collections; | ||
31 | //using LuaInterface; | ||
32 | using libsecondlife; | ||
33 | |||
34 | namespace OpenSim | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// Description of Script_manager. | ||
38 | /// </summary> | ||
39 | public class ScriptManager | ||
40 | { | ||
41 | //public LuaInterface.Lua Lu; | ||
42 | //private ArrayList scripts; | ||
43 | //private prim_info current_prim; | ||
44 | |||
45 | public ScriptManager() | ||
46 | { | ||
47 | } | ||
48 | |||
49 | /*public void start_up (Lua lua, App ap) | ||
50 | { | ||
51 | this.Lu=lua; | ||
52 | //register any lua routines , like check finish script one | ||
53 | Lu.OpenMathLib(); | ||
54 | }*/ | ||
55 | |||
56 | private void RegisterFunctions() | ||
57 | { | ||
58 | //lu.RegisterFunction( "RegisterScript",this,this.GetType().GetMethod("ScriptRegister")); | ||
59 | //lu.RegisterFunction( "MoveObject",this,this.GetType().GetMethod("MoveObject")); | ||
60 | //lu.RegisterFunction( "Say",this,this.GetType().GetMethod("Say")); | ||
61 | |||
62 | } | ||
63 | |||
64 | public void Call_tick(PrimInfo prim) | ||
65 | { | ||
66 | //set current prim and then call tick function in linked script | ||
67 | } | ||
68 | public void Call_touch(PrimInfo prim) | ||
69 | { | ||
70 | //set current prim and then call clicked function in linked script | ||
71 | |||
72 | } | ||
73 | public void Call_on_rex(PrimInfo prim) | ||
74 | { | ||
75 | //set current prim and then call clicked function in linked script | ||
76 | |||
77 | } | ||
78 | |||
79 | #region Lua Functions | ||
80 | |||
81 | public void ScriptRegister(script_object_interface script) | ||
82 | { | ||
83 | //called by scripts to register themselves | ||
84 | } | ||
85 | public void MoveObject(float x , float y, float z) | ||
86 | { | ||
87 | |||
88 | } | ||
89 | public void Say(string message) | ||
90 | { | ||
91 | |||
92 | } | ||
93 | #endregion | ||
94 | |||
95 | } | ||
96 | |||
97 | public interface script_object_interface | ||
98 | { | ||
99 | void frame_tick(); | ||
100 | void touch(int num); | ||
101 | void on_rex(int num); | ||
102 | } | ||
103 | } | ||
diff --git a/Second-server.csproj b/Second-server.csproj deleted file mode 100644 index c263a32..0000000 --- a/Second-server.csproj +++ /dev/null | |||
@@ -1,61 +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.Controller</StartupObject> | ||
10 | </PropertyGroup> | ||
11 | <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
12 | <OutputPath>bin\Debug\</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\Release\</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>lib\Axiom.MathLib.dll</HintPath> | ||
31 | </Reference> | ||
32 | <Reference Include="libsecondlife, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
33 | <SpecificVersion>False</SpecificVersion> | ||
34 | <HintPath>..\..\..\..\..\dev\libsecondlife\bin\libsecondlife.dll</HintPath> | ||
35 | </Reference> | ||
36 | <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL"> | ||
37 | <SpecificVersion>False</SpecificVersion> | ||
38 | <HintPath>lib\log4net.dll</HintPath> | ||
39 | </Reference> | ||
40 | <Reference Include="System" /> | ||
41 | <Reference Include="System.Data" /> | ||
42 | <Reference Include="System.Xml" /> | ||
43 | </ItemGroup> | ||
44 | <ItemGroup> | ||
45 | <Compile Include="AssemblyInfo.cs" /> | ||
46 | <Compile Include="Agent_Manager.cs" /> | ||
47 | <Compile Include="Controller.cs" /> | ||
48 | <Compile Include="Prim_manager.cs" /> | ||
49 | <Compile Include="Login_manager.cs" /> | ||
50 | <Compile Include="Physics_manager.cs" /> | ||
51 | <Compile Include="Script_manager.cs" /> | ||
52 | <Compile Include="Server.cs" /> | ||
53 | <Compile Include="StorageManager.cs" /> | ||
54 | <Compile Include="GridManager.cs" /> | ||
55 | <Compile Include="Globals.cs" /> | ||
56 | <Compile Include="InventoryManager.cs" /> | ||
57 | <Compile Include="SceneGraphManager.cs" /> | ||
58 | <Compile Include="AssetManagement.cs" /> | ||
59 | </ItemGroup> | ||
60 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | ||
61 | </Project> \ No newline at end of file | ||
diff --git a/Second-server.sln b/Second-server.sln deleted file mode 100644 index 44be1db..0000000 --- a/Second-server.sln +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 |  | ||
2 | Microsoft Visual Studio Solution File, Format Version 9.00 | ||
3 | # SharpDevelop 2.1.0.2017 | ||
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|Any CPU.ActiveCfg = Debug|Any CPU | ||
16 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
17 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|.NET 1.1.ActiveCfg = Release|Any CPU | ||
18 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
19 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
20 | {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1 | ||
21 | {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1 | ||
22 | {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
23 | {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
24 | {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1 | ||
25 | {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 | ||
26 | {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
27 | {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
28 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1 | ||
29 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 | ||
30 | EndGlobalSection | ||
31 | GlobalSection(SolutionProperties) = preSolution | ||
32 | HideSolutionNode = FALSE | ||
33 | EndGlobalSection | ||
34 | EndGlobal | ||
diff --git a/Server.cs b/Server.cs deleted file mode 100644 index 5e1bb5a..0000000 --- a/Server.cs +++ /dev/null | |||
@@ -1,645 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the <organization> nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using libsecondlife; | ||
31 | using System.Collections; | ||
32 | using libsecondlife.Packets; | ||
33 | using libsecondlife.AssetSystem; | ||
34 | using System.Net; | ||
35 | using System.Net.Sockets; | ||
36 | using System.Timers; | ||
37 | |||
38 | //really hacked , messy code | ||
39 | |||
40 | namespace OpenSim | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// Description of Server. | ||
44 | /// </summary> | ||
45 | public interface ServerCallback | ||
46 | { | ||
47 | //should replace with delegates | ||
48 | void MainCallback(Packet pack, UserAgentInfo User_info); | ||
49 | void NewUserCallback(UserAgentInfo User_info); | ||
50 | void ErrorCallback(string text); | ||
51 | } | ||
52 | public class Server | ||
53 | { | ||
54 | /// <summary>A public reference to the client that this Simulator object | ||
55 | /// is attached to</summary> | ||
56 | //public SecondLife Client; | ||
57 | |||
58 | /// <summary>The Region class that this Simulator wraps</summary> | ||
59 | // public Region Region; | ||
60 | |||
61 | /// <summary> | ||
62 | /// Used internally to track sim disconnections, do not modify this | ||
63 | /// variable | ||
64 | /// </summary> | ||
65 | public bool DisconnectCandidate = false; | ||
66 | |||
67 | /// <summary> | ||
68 | /// The ID number associated with this particular connection to the | ||
69 | /// simulator, used to emulate TCP connections. This is used | ||
70 | /// internally for packets that have a CircuitCode field | ||
71 | /// </summary> | ||
72 | public uint CircuitCode | ||
73 | { | ||
74 | get { return circuitCode; } | ||
75 | set { circuitCode = value; } | ||
76 | } | ||
77 | |||
78 | /// <summary> | ||
79 | /// The IP address and port of the server | ||
80 | /// </summary> | ||
81 | public IPEndPoint IPEndPoint | ||
82 | { | ||
83 | get { return ipEndPoint; } | ||
84 | } | ||
85 | |||
86 | /// <summary> | ||
87 | /// A boolean representing whether there is a working connection to the | ||
88 | /// simulator or not | ||
89 | /// </summary> | ||
90 | public bool Connected | ||
91 | { | ||
92 | get { return connected; } | ||
93 | } | ||
94 | |||
95 | private ServerCallback CallbackObject; | ||
96 | private uint Sequence = 0; | ||
97 | private object SequenceLock = new object(); | ||
98 | private byte[] RecvBuffer = new byte[4096]; | ||
99 | private byte[] ZeroBuffer = new byte[8192]; | ||
100 | private byte[] ZeroOutBuffer = new byte[4096]; | ||
101 | private Socket Connection = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); | ||
102 | private AsyncCallback ReceivedData; | ||
103 | private bool connected = false; | ||
104 | private uint circuitCode; | ||
105 | private IPEndPoint ipEndPoint; | ||
106 | private EndPoint endPoint; | ||
107 | private IPEndPoint ipeSender; | ||
108 | private EndPoint epSender; | ||
109 | private System.Timers.Timer AckTimer; | ||
110 | private Server_Settings Settings=new Server_Settings(); | ||
111 | public ArrayList User_agents=new ArrayList(); | ||
112 | |||
113 | /// <summary> | ||
114 | /// Constructor for Simulator | ||
115 | /// </summary> | ||
116 | /// <param name="client"></param> | ||
117 | /// <param name="callbacks"></param> | ||
118 | /// <param name="circuit"></param> | ||
119 | /// <param name="ip"></param> | ||
120 | /// <param name="port"></param> | ||
121 | public Server(ServerCallback s_callback) | ||
122 | { | ||
123 | |||
124 | this.CallbackObject=s_callback; //should be using delegate | ||
125 | AckTimer = new System.Timers.Timer(Settings.NETWORK_TICK_LENGTH); | ||
126 | AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); | ||
127 | |||
128 | // Initialize the callback for receiving a new packet | ||
129 | ReceivedData = new AsyncCallback(this.OnReceivedData); | ||
130 | |||
131 | // Client.Log("Connecting to " + ip.ToString() + ":" + port, Helpers.LogLevel.Info); | ||
132 | |||
133 | try | ||
134 | { | ||
135 | // Create an endpoint that we will be communicating with (need it in two | ||
136 | // types due to .NET weirdness) | ||
137 | // ipEndPoint = new IPEndPoint(ip, port); | ||
138 | ipEndPoint = new IPEndPoint(IPAddress.Any, Globals.Instance.IpPort); | ||
139 | endPoint = (EndPoint)ipEndPoint; | ||
140 | |||
141 | // Associate this simulator's socket with the given ip/port and start listening | ||
142 | Connection.Bind(endPoint); | ||
143 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | ||
144 | //The epSender identifies the incoming clients | ||
145 | epSender = (EndPoint) ipeSender; | ||
146 | Connection.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | ||
147 | |||
148 | // Start the ACK timer | ||
149 | AckTimer.Start(); | ||
150 | } | ||
151 | catch (Exception e) | ||
152 | { | ||
153 | |||
154 | System.Console.WriteLine(e.Message); | ||
155 | } | ||
156 | } | ||
157 | |||
158 | /// <summary> | ||
159 | /// Disconnect a Simulator | ||
160 | /// </summary> | ||
161 | public void Disconnect() | ||
162 | { | ||
163 | if (connected) | ||
164 | { | ||
165 | connected = false; | ||
166 | AckTimer.Stop(); | ||
167 | |||
168 | // Send the CloseCircuit notice | ||
169 | CloseCircuitPacket close = new CloseCircuitPacket(); | ||
170 | |||
171 | if (Connection.Connected) | ||
172 | { | ||
173 | try | ||
174 | { | ||
175 | // Connection.Send(close.ToBytes()); | ||
176 | } | ||
177 | catch (SocketException) | ||
178 | { | ||
179 | // There's a high probability of this failing if the network is | ||
180 | // disconnecting, so don't even bother logging the error | ||
181 | } | ||
182 | } | ||
183 | |||
184 | try | ||
185 | { | ||
186 | // Shut the socket communication down | ||
187 | // Connection.Shutdown(SocketShutdown.Both); | ||
188 | } | ||
189 | catch (SocketException) | ||
190 | { | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | |||
195 | /// <summary> | ||
196 | /// Sends a packet | ||
197 | /// </summary> | ||
198 | /// <param name="packet">Packet to be sent</param> | ||
199 | /// <param name="incrementSequence">Increment sequence number?</param> | ||
200 | public void SendPacket(Packet packet, bool incrementSequence, UserAgentInfo User_info) | ||
201 | { | ||
202 | byte[] buffer; | ||
203 | int bytes; | ||
204 | |||
205 | if (!connected && packet.Type != PacketType.UseCircuitCode) | ||
206 | { | ||
207 | // Client.Log("Trying to send a " + packet.Type.ToString() + " packet when the socket is closed", | ||
208 | // Helpers.LogLevel.Info); | ||
209 | |||
210 | return; | ||
211 | } | ||
212 | |||
213 | if (packet.Header.AckList.Length > 0) | ||
214 | { | ||
215 | // Scrub any appended ACKs since all of the ACK handling is done here | ||
216 | packet.Header.AckList = new uint[0]; | ||
217 | } | ||
218 | packet.Header.AppendedAcks = false; | ||
219 | |||
220 | // Keep track of when this packet was sent out | ||
221 | packet.TickCount = Environment.TickCount; | ||
222 | |||
223 | if (incrementSequence) | ||
224 | { | ||
225 | // Set the sequence number | ||
226 | lock (SequenceLock) | ||
227 | { | ||
228 | if (Sequence > Settings.MAX_SEQUENCE) | ||
229 | Sequence = 1; | ||
230 | else | ||
231 | Sequence++; | ||
232 | packet.Header.Sequence = Sequence; | ||
233 | } | ||
234 | |||
235 | if (packet.Header.Reliable) | ||
236 | { | ||
237 | lock (User_info.NeedAck) | ||
238 | { | ||
239 | if (!User_info.NeedAck.ContainsKey(packet.Header.Sequence)) | ||
240 | { | ||
241 | User_info.NeedAck.Add(packet.Header.Sequence, packet); | ||
242 | } | ||
243 | else | ||
244 | { | ||
245 | // Client.Log("Attempted to add a duplicate sequence number (" + | ||
246 | // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + | ||
247 | // packet.Type.ToString(), Helpers.LogLevel.Warning); | ||
248 | } | ||
249 | } | ||
250 | |||
251 | // Don't append ACKs to resent packets, in case that's what was causing the | ||
252 | // delivery to fail | ||
253 | if (!packet.Header.Resent) | ||
254 | { | ||
255 | // Append any ACKs that need to be sent out to this packet | ||
256 | lock (User_info.PendingAcks) | ||
257 | { | ||
258 | if (User_info.PendingAcks.Count > 0 && User_info.PendingAcks.Count < Settings.MAX_APPENDED_ACKS && | ||
259 | packet.Type != PacketType.PacketAck && | ||
260 | packet.Type != PacketType.LogoutRequest) | ||
261 | { | ||
262 | packet.Header.AckList = new uint[User_info.PendingAcks.Count]; | ||
263 | int i = 0; | ||
264 | |||
265 | foreach (uint ack in User_info.PendingAcks.Values) | ||
266 | { | ||
267 | packet.Header.AckList[i] = ack; | ||
268 | i++; | ||
269 | } | ||
270 | |||
271 | User_info.PendingAcks.Clear(); | ||
272 | packet.Header.AppendedAcks = true; | ||
273 | } | ||
274 | } | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | |||
279 | // Serialize the packet | ||
280 | buffer = packet.ToBytes(); | ||
281 | bytes = buffer.Length; | ||
282 | |||
283 | try | ||
284 | { | ||
285 | // Zerocode if needed | ||
286 | if (packet.Header.Zerocoded) | ||
287 | { | ||
288 | lock (ZeroOutBuffer) | ||
289 | { | ||
290 | bytes = Helpers.ZeroEncode(buffer, bytes, ZeroOutBuffer); | ||
291 | Connection.SendTo(ZeroOutBuffer, bytes, SocketFlags.None,User_info.endpoint); | ||
292 | } | ||
293 | } | ||
294 | else | ||
295 | { | ||
296 | |||
297 | Connection.SendTo(buffer, bytes, SocketFlags.None,User_info.endpoint); | ||
298 | } | ||
299 | } | ||
300 | catch (SocketException) | ||
301 | { | ||
302 | //Client.Log("Tried to send a " + packet.Type.ToString() + " on a closed socket", | ||
303 | // Helpers.LogLevel.Warning); | ||
304 | |||
305 | Disconnect(); | ||
306 | } | ||
307 | } | ||
308 | |||
309 | /// <summary> | ||
310 | /// Send a raw byte array payload as a packet | ||
311 | /// </summary> | ||
312 | /// <param name="payload">The packet payload</param> | ||
313 | /// <param name="setSequence">Whether the second, third, and fourth bytes | ||
314 | /// should be modified to the current stream sequence number</param> | ||
315 | /// <summary> | ||
316 | /// Returns Simulator Name as a String | ||
317 | /// </summary> | ||
318 | /// <returns></returns> | ||
319 | public override string ToString() | ||
320 | { | ||
321 | return( " (" + ipEndPoint.ToString() + ")"); | ||
322 | } | ||
323 | |||
324 | /// <summary> | ||
325 | /// Sends out pending acknowledgements | ||
326 | /// </summary> | ||
327 | private void SendAcks(UserAgentInfo User_info) | ||
328 | { | ||
329 | lock (User_info.PendingAcks) | ||
330 | { | ||
331 | if (connected && User_info.PendingAcks.Count > 0) | ||
332 | { | ||
333 | if (User_info.PendingAcks.Count > 250) | ||
334 | { | ||
335 | // FIXME: Handle the odd case where we have too many pending ACKs queued up | ||
336 | //Client.Log("Too many ACKs queued up!", Helpers.LogLevel.Error); | ||
337 | return; | ||
338 | } | ||
339 | |||
340 | int i = 0; | ||
341 | PacketAckPacket acks = new PacketAckPacket(); | ||
342 | acks.Packets = new PacketAckPacket.PacketsBlock[User_info.PendingAcks.Count]; | ||
343 | |||
344 | foreach (uint ack in User_info.PendingAcks.Values) | ||
345 | { | ||
346 | acks.Packets[i] = new PacketAckPacket.PacketsBlock(); | ||
347 | acks.Packets[i].ID = ack; | ||
348 | i++; | ||
349 | } | ||
350 | |||
351 | acks.Header.Reliable = false; | ||
352 | SendPacket(acks, true,User_info); | ||
353 | |||
354 | User_info.PendingAcks.Clear(); | ||
355 | } | ||
356 | } | ||
357 | } | ||
358 | /// <summary> | ||
359 | /// Resend unacknowledged packets | ||
360 | /// </summary> | ||
361 | private void ResendUnacked(UserAgentInfo User_info) | ||
362 | { | ||
363 | if (connected) | ||
364 | { | ||
365 | int now = Environment.TickCount; | ||
366 | |||
367 | lock (User_info.NeedAck) | ||
368 | { | ||
369 | foreach (Packet packet in User_info.NeedAck.Values) | ||
370 | { | ||
371 | if (now - packet.TickCount > Settings.RESEND_TIMEOUT) | ||
372 | { | ||
373 | // Client.Log("Resending " + packet.Type.ToString() + " packet, " + | ||
374 | // (now - packet.TickCount) + "ms have passed", Helpers.LogLevel.Info); | ||
375 | |||
376 | packet.Header.Resent = true; | ||
377 | SendPacket(packet, false,User_info); | ||
378 | } | ||
379 | } | ||
380 | } | ||
381 | } | ||
382 | } | ||
383 | /// <summary> | ||
384 | /// Callback handler for incomming data | ||
385 | /// </summary> | ||
386 | /// <param name="result"></param> | ||
387 | private void OnReceivedData(IAsyncResult result) | ||
388 | { | ||
389 | |||
390 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | ||
391 | epSender = (EndPoint)ipeSender; | ||
392 | Packet packet = null; | ||
393 | int numBytes; | ||
394 | |||
395 | // If we're receiving data the sim connection is open | ||
396 | connected = true; | ||
397 | |||
398 | // Update the disconnect flag so this sim doesn't time out | ||
399 | DisconnectCandidate = false; | ||
400 | UserAgentInfo User_info=null; | ||
401 | |||
402 | lock (RecvBuffer) | ||
403 | { | ||
404 | // Retrieve the incoming packet | ||
405 | try | ||
406 | { | ||
407 | numBytes = Connection.EndReceiveFrom(result, ref epSender); | ||
408 | |||
409 | //find user_agent_info | ||
410 | |||
411 | int packetEnd = numBytes - 1; | ||
412 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); | ||
413 | |||
414 | |||
415 | //should check if login/useconnection packet first | ||
416 | if (packet.Type == PacketType.UseCircuitCode) | ||
417 | { | ||
418 | UseCircuitCodePacket cir_pack=(UseCircuitCodePacket)packet; | ||
419 | UserAgentInfo new_user=new UserAgentInfo(); | ||
420 | new_user.circuitCode=cir_pack.CircuitCode.Code; | ||
421 | new_user.AgentID=cir_pack.CircuitCode.ID; | ||
422 | new_user.SessionID=cir_pack.CircuitCode.SessionID; | ||
423 | new_user.endpoint=epSender; | ||
424 | new_user.Inbox = new Queue<uint>(Settings.INBOX_SIZE); | ||
425 | |||
426 | this.CallbackObject.NewUserCallback(new_user); | ||
427 | this.User_agents.Add(new_user); | ||
428 | |||
429 | } | ||
430 | |||
431 | |||
432 | UserAgentInfo temp_agent=null; | ||
433 | IPEndPoint send_ip=(IPEndPoint)epSender; | ||
434 | // this.callback_object.error("incoming: address is "+send_ip.Address +"port number is: "+send_ip.Port.ToString()); | ||
435 | |||
436 | for(int ii=0; ii<this.User_agents.Count ; ii++) | ||
437 | { | ||
438 | temp_agent=(UserAgentInfo)this.User_agents[ii]; | ||
439 | IPEndPoint ag_ip=(IPEndPoint)temp_agent.endpoint; | ||
440 | //this.callback_object.error("searching: address is "+ag_ip.Address +"port number is: "+ag_ip.Port.ToString()); | ||
441 | |||
442 | if((ag_ip.Address.ToString()==send_ip.Address.ToString()) && (ag_ip.Port.ToString()==send_ip.Port.ToString())) | ||
443 | { | ||
444 | //this.callback_object.error("found user"); | ||
445 | User_info=temp_agent; | ||
446 | break; | ||
447 | } | ||
448 | } | ||
449 | |||
450 | Connection.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | ||
451 | } | ||
452 | catch (SocketException) | ||
453 | { | ||
454 | // Client.Log(endPoint.ToString() + " socket is closed, shutting down " + this.Region.Name, | ||
455 | // Helpers.LogLevel.Info); | ||
456 | |||
457 | connected = false; | ||
458 | //Network.DisconnectSim(this); | ||
459 | return; | ||
460 | } | ||
461 | } | ||
462 | if(User_info==null) | ||
463 | { | ||
464 | |||
465 | //error finding agent | ||
466 | this.CallbackObject.ErrorCallback("no user found"); | ||
467 | return; | ||
468 | } | ||
469 | |||
470 | // Fail-safe check | ||
471 | if (packet == null) | ||
472 | { | ||
473 | this.CallbackObject.ErrorCallback("couldn't build packet"); | ||
474 | // Client.Log("Couldn't build a message from the incoming data", Helpers.LogLevel.Warning); | ||
475 | return; | ||
476 | } | ||
477 | //this.callback_object.error("past tests"); | ||
478 | // Track the sequence number for this packet if it's marked as reliable | ||
479 | if (packet.Header.Reliable) | ||
480 | { | ||
481 | if (User_info.PendingAcks.Count > Settings.MAX_PENDING_ACKS) | ||
482 | { | ||
483 | SendAcks(User_info); | ||
484 | } | ||
485 | |||
486 | // Check if we already received this packet | ||
487 | if (User_info.Inbox.Contains(packet.Header.Sequence)) | ||
488 | { | ||
489 | //Client.Log("Received a duplicate " + packet.Type.ToString() + ", sequence=" + | ||
490 | // packet.Header.Sequence + ", resent=" + ((packet.Header.Resent) ? "Yes" : "No") + | ||
491 | // ", Inbox.Count=" + Inbox.Count + ", NeedAck.Count=" + NeedAck.Count, | ||
492 | // Helpers.LogLevel.Info); | ||
493 | |||
494 | // Send an ACK for this packet immediately | ||
495 | //SendAck(packet.Header.Sequence); | ||
496 | |||
497 | // TESTING: Try just queuing up ACKs for resent packets instead of immediately triggering an ACK | ||
498 | lock (User_info.PendingAcks) | ||
499 | { | ||
500 | uint sequence = (uint)packet.Header.Sequence; | ||
501 | if (!User_info.PendingAcks.ContainsKey(sequence)) { User_info.PendingAcks[sequence] = sequence; } | ||
502 | } | ||
503 | |||
504 | // Avoid firing a callback twice for the same packet | ||
505 | // this.callback_object.error("avoiding callback"); | ||
506 | return; | ||
507 | } | ||
508 | else | ||
509 | { | ||
510 | lock (User_info.PendingAcks) | ||
511 | { | ||
512 | uint sequence = (uint)packet.Header.Sequence; | ||
513 | if (!User_info.PendingAcks.ContainsKey(sequence)) { User_info.PendingAcks[sequence] = sequence; } | ||
514 | } | ||
515 | } | ||
516 | } | ||
517 | |||
518 | // Add this packet to our inbox | ||
519 | lock (User_info.Inbox) | ||
520 | { | ||
521 | while (User_info.Inbox.Count >= Settings.INBOX_SIZE) | ||
522 | { | ||
523 | User_info.Inbox.Dequeue(); | ||
524 | } | ||
525 | User_info.Inbox.Enqueue(packet.Header.Sequence); | ||
526 | } | ||
527 | |||
528 | // Handle appended ACKs | ||
529 | if (packet.Header.AppendedAcks) | ||
530 | { | ||
531 | lock (User_info.NeedAck) | ||
532 | { | ||
533 | foreach (uint ack in packet.Header.AckList) | ||
534 | { | ||
535 | User_info.NeedAck.Remove(ack); | ||
536 | } | ||
537 | } | ||
538 | } | ||
539 | |||
540 | // Handle PacketAck packets | ||
541 | if (packet.Type == PacketType.PacketAck) | ||
542 | { | ||
543 | PacketAckPacket ackPacket = (PacketAckPacket)packet; | ||
544 | |||
545 | lock (User_info.NeedAck) | ||
546 | { | ||
547 | foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) | ||
548 | { | ||
549 | User_info.NeedAck.Remove(block.ID); | ||
550 | } | ||
551 | } | ||
552 | } | ||
553 | |||
554 | this.CallbackObject.MainCallback(packet,User_info); | ||
555 | |||
556 | } | ||
557 | |||
558 | private void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) | ||
559 | { | ||
560 | if (connected) | ||
561 | { | ||
562 | |||
563 | //TODO for each user_agent_info | ||
564 | for(int i=0; i<this.User_agents.Count; i++) | ||
565 | { | ||
566 | UserAgentInfo user=(UserAgentInfo)this.User_agents[i]; | ||
567 | |||
568 | SendAcks(user); | ||
569 | ResendUnacked(user); | ||
570 | } | ||
571 | } | ||
572 | } | ||
573 | } | ||
574 | |||
575 | public class Server_Settings | ||
576 | { | ||
577 | /// <summary>The version of libsecondlife (not the SL protocol itself)</summary> | ||
578 | public string VERSION = "libsecondlife 0.0.9"; | ||
579 | /// <summary>XML-RPC login server to connect to</summary> | ||
580 | public string LOGIN_SERVER = "https://login.agni.lindenlab.com/cgi-bin/login.cgi"; | ||
581 | |||
582 | /// <summary>Millisecond interval between ticks, where all ACKs are | ||
583 | /// sent out and the age of unACKed packets is checked</summary> | ||
584 | public readonly int NETWORK_TICK_LENGTH = 500; | ||
585 | /// <summary>The maximum value of a packet sequence number. After that | ||
586 | /// we assume the sequence number just rolls over? Or maybe the | ||
587 | /// protocol isn't able to sustain a connection past that</summary> | ||
588 | public readonly int MAX_SEQUENCE = 0xFFFFFF; | ||
589 | /// <summary>Number of milliseconds before a teleport attempt will time | ||
590 | /// out</summary> | ||
591 | public readonly int TELEPORT_TIMEOUT = 18 * 1000; | ||
592 | |||
593 | /// <summary>Number of milliseconds before NetworkManager.Logout() will time out</summary> | ||
594 | public int LOGOUT_TIMEOUT = 5 * 1000; | ||
595 | /// <summary>Number of milliseconds for xml-rpc to timeout</summary> | ||
596 | public int LOGIN_TIMEOUT = 30 * 1000; | ||
597 | /// <summary>The maximum size of the sequence number inbox, used to | ||
598 | /// check for resent and/or duplicate packets</summary> | ||
599 | public int INBOX_SIZE = 100; | ||
600 | /// <summary>Milliseconds before a packet is assumed lost and resent</summary> | ||
601 | public int RESEND_TIMEOUT = 4000; | ||
602 | /// <summary>Milliseconds before the connection to a simulator is | ||
603 | /// assumed lost</summary> | ||
604 | public int SIMULATOR_TIMEOUT = 15000; | ||
605 | /// <summary>Maximum number of queued ACKs to be sent before SendAcks() | ||
606 | /// is forced</summary> | ||
607 | public int MAX_PENDING_ACKS = 10; | ||
608 | /// <summary>Maximum number of ACKs to append to a packet</summary> | ||
609 | public int MAX_APPENDED_ACKS = 10; | ||
610 | /// <summary>Cost of uploading an asset</summary> | ||
611 | public int UPLOAD_COST { get { return priceUpload; } } | ||
612 | |||
613 | |||
614 | private int priceUpload = 0; | ||
615 | |||
616 | public Server_Settings() | ||
617 | { | ||
618 | |||
619 | } | ||
620 | } | ||
621 | |||
622 | public class UserAgentInfo | ||
623 | { | ||
624 | public EndPoint endpoint; | ||
625 | public LLUUID AgentID; | ||
626 | public LLUUID SessionID; | ||
627 | public uint circuitCode; | ||
628 | public string name; | ||
629 | public uint localID; | ||
630 | public string first_name; | ||
631 | public string last_name; | ||
632 | |||
633 | public Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); | ||
634 | // Sequence numbers of packets we've received from the simulator | ||
635 | public Queue<uint> Inbox; | ||
636 | // ACKs that are queued up to be sent to the simulator | ||
637 | public Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); | ||
638 | |||
639 | public UserAgentInfo() | ||
640 | { | ||
641 | |||
642 | } | ||
643 | } | ||
644 | |||
645 | } | ||
diff --git a/StorageManager.cs b/StorageManager.cs deleted file mode 100644 index 596e4e6..0000000 --- a/StorageManager.cs +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the <organization> nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using libsecondlife; | ||
31 | using System.Collections; | ||
32 | using libsecondlife.Packets; | ||
33 | using libsecondlife.AssetSystem; | ||
34 | using System.IO; | ||
35 | |||
36 | namespace OpenSim | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Description of StorageManager. | ||
40 | /// </summary> | ||
41 | public class StorageManager | ||
42 | { | ||
43 | public StorageManager() | ||
44 | { | ||
45 | } | ||
46 | } | ||
47 | |||
48 | public class AssetStorage | ||
49 | { | ||
50 | public LLUUID Full_ID; | ||
51 | public byte Type; | ||
52 | } | ||
53 | } | ||
diff --git a/Texture_manager.cs b/Texture_manager.cs deleted file mode 100644 index daf1452..0000000 --- a/Texture_manager.cs +++ /dev/null | |||
@@ -1,238 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSim project, http://sim.opensecondlife.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 libsecondlife; | ||
33 | using System.Collections; | ||
34 | using libsecondlife.Packets; | ||
35 | using libsecondlife.AssetSystem; | ||
36 | using System.IO; | ||
37 | |||
38 | |||
39 | namespace OpenSim | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// Description of Texture_manager. | ||
43 | /// </summary> | ||
44 | public class TextureManager | ||
45 | { | ||
46 | public Dictionary<libsecondlife.LLUUID,TextureImage> textures; | ||
47 | public ArrayList requests=new ArrayList(); //should change to a generic | ||
48 | public ArrayList uploads=new ArrayList(); | ||
49 | private Server server; | ||
50 | |||
51 | public TextureManager(Server serve) | ||
52 | { | ||
53 | server=serve; | ||
54 | textures=new Dictionary<libsecondlife.LLUUID,TextureImage> (); | ||
55 | this.initialise(); | ||
56 | } | ||
57 | |||
58 | public void AddRequest(User_Agent_info user, LLUUID image_id) | ||
59 | { | ||
60 | |||
61 | if(!this.textures.ContainsKey(image_id)) | ||
62 | { | ||
63 | //not found image so send back image not in data base message | ||
64 | ImageNotInDatabasePacket im_not=new ImageNotInDatabasePacket(); | ||
65 | im_not.ImageID.ID=image_id; | ||
66 | server.SendPacket(im_not,true,user); | ||
67 | return; | ||
68 | } | ||
69 | TextureImage imag=this.textures[image_id]; | ||
70 | TextureRequest req=new TextureRequest(); | ||
71 | req.RequestUser=user; | ||
72 | req.RequestImage=image_id; | ||
73 | req.image_info=imag; | ||
74 | |||
75 | if(imag.data.LongLength>1000) //should be bigger or smaller? | ||
76 | { | ||
77 | //over 1000 bytes so split up file | ||
78 | req.num_packets=(int)imag.data.LongLength/1000; | ||
79 | req.num_packets++; | ||
80 | } | ||
81 | else | ||
82 | { | ||
83 | req.num_packets=1; | ||
84 | } | ||
85 | |||
86 | this.requests.Add(req); | ||
87 | |||
88 | } | ||
89 | |||
90 | public void AddTexture(LLUUID image_id, string name, byte[] data) | ||
91 | { | ||
92 | |||
93 | } | ||
94 | public void DoWork(ulong time) | ||
95 | { | ||
96 | if(this.requests.Count==0) | ||
97 | { | ||
98 | //no requests waiting | ||
99 | return; | ||
100 | } | ||
101 | int num; | ||
102 | //should be running in its own thread but for now is called by timer | ||
103 | if(this.requests.Count<5) | ||
104 | { | ||
105 | //lower than 5 so do all of them | ||
106 | num=this.requests.Count; | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | num=5; | ||
111 | } | ||
112 | TextureRequest req; | ||
113 | for(int i=0; i<num; i++) | ||
114 | { | ||
115 | req=(TextureRequest)this.requests[i]; | ||
116 | |||
117 | if(req.packet_counter==0) | ||
118 | { | ||
119 | //first time for this request so send imagedata packet | ||
120 | if(req.num_packets==1) | ||
121 | { | ||
122 | //only one packet so send whole file | ||
123 | ImageDataPacket im=new ImageDataPacket(); | ||
124 | im.ImageID.Packets=1; | ||
125 | im.ImageID.ID=req.image_info.Full_ID; | ||
126 | im.ImageID.Size=(uint)req.image_info.data.Length; | ||
127 | im.ImageData.Data=req.image_info.data; | ||
128 | im.ImageID.Codec=2; | ||
129 | server.SendPacket(im,true,req.RequestUser); | ||
130 | req.packet_counter++; | ||
131 | req.image_info.last_used=time; | ||
132 | System.Console.WriteLine("sent texture: "+req.image_info.Full_ID); | ||
133 | } | ||
134 | else | ||
135 | { | ||
136 | //more than one packet so split file up | ||
137 | } | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | //send imagepacket | ||
142 | |||
143 | } | ||
144 | } | ||
145 | |||
146 | //remove requests that have been completed | ||
147 | for(int i=0; i<num; i++) | ||
148 | { | ||
149 | req=(TextureRequest)this.requests[i]; | ||
150 | if(req.packet_counter==req.num_packets) | ||
151 | { | ||
152 | this.requests.Remove(req); | ||
153 | } | ||
154 | } | ||
155 | } | ||
156 | |||
157 | public void RecieveTexture(Packet pack) | ||
158 | { | ||
159 | |||
160 | } | ||
161 | |||
162 | private void initialise() | ||
163 | { | ||
164 | |||
165 | TextureImage im=new TextureImage(); | ||
166 | im.filename="testpic2.jp2"; | ||
167 | im.Full_ID=new LLUUID("00000000-0000-0000-5005-000000000005"); | ||
168 | im.Name="test Texture"; | ||
169 | this.LoadImage(im); | ||
170 | this.textures.Add(im.Full_ID,im); | ||
171 | |||
172 | //Change these filenames to images you want to use. | ||
173 | im=new TextureImage(); | ||
174 | im.filename="map_base.jp2"; | ||
175 | im.Full_ID=new LLUUID("00000000-0000-0000-7007-000000000006"); | ||
176 | this.LoadImage(im); | ||
177 | this.textures.Add(im.Full_ID,im); | ||
178 | |||
179 | im=new TextureImage(); | ||
180 | im.filename="map1.jp2"; | ||
181 | im.Full_ID=new LLUUID("00000000-0000-0000-7009-000000000008"); | ||
182 | this.LoadImage(im); | ||
183 | this.textures.Add(im.Full_ID,im); | ||
184 | |||
185 | } | ||
186 | private void LoadImage(TextureImage im) | ||
187 | { | ||
188 | //should request Image from StorageManager | ||
189 | //but for now read from file | ||
190 | |||
191 | string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\textures\"; | ||
192 | string filename=data_path+@im.filename; | ||
193 | FileInfo fInfo = new FileInfo(filename); | ||
194 | |||
195 | long numBytes = fInfo.Length; | ||
196 | |||
197 | FileStream fStream = new FileStream(filename, FileMode.Open, FileAccess.Read); | ||
198 | byte[] idata=new byte[numBytes]; | ||
199 | BinaryReader br = new BinaryReader(fStream); | ||
200 | idata= br.ReadBytes((int)numBytes); | ||
201 | br.Close(); | ||
202 | fStream.Close(); | ||
203 | im.data=idata; | ||
204 | im.loaded=true; | ||
205 | } | ||
206 | |||
207 | } | ||
208 | |||
209 | public class TextureRequest | ||
210 | { | ||
211 | public User_Agent_info RequestUser; | ||
212 | public LLUUID RequestImage; | ||
213 | public TextureImage image_info; | ||
214 | public long data_pointer=0; | ||
215 | public int num_packets=0; | ||
216 | public int packet_counter=0; | ||
217 | |||
218 | public TextureRequest() | ||
219 | { | ||
220 | |||
221 | } | ||
222 | } | ||
223 | public class TextureImage: AssetBase | ||
224 | { | ||
225 | //public byte[] data; | ||
226 | //public LLUUID Full_ID; | ||
227 | //public string name; | ||
228 | public string filename; | ||
229 | public bool loaded; | ||
230 | public ulong last_used; //need to add a tick/time counter and keep record | ||
231 | // of how often images are requested to unload unused ones. | ||
232 | |||
233 | public TextureImage() | ||
234 | { | ||
235 | |||
236 | } | ||
237 | } | ||
238 | } | ||
diff --git a/bin/Release/(TwoRegion)Grid.ini b/bin/Release/(TwoRegion)Grid.ini deleted file mode 100644 index d631d6c..0000000 --- a/bin/Release/(TwoRegion)Grid.ini +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | <Root> | ||
2 | <Grid> | ||
3 | <Region Name="Test Sandbox" ImageID="00000000-0000-0000-7009-000000000008" IP_Address="127.0.0.1" IP_Port="1000" Location_X="997" Location_Y="996" /> | ||
4 | <Region Name="The Other" ImageID="00000000-0000-0000-7009-000000000008" IP_Address="127.0.0.1" IP_Port="1020" Location_X="996" Location_Y="996" /> | ||
5 | <CurrentRegion RegionHandle="1096213093147648" LoginServer="true" /> | ||
6 | </Grid> | ||
7 | </Root> \ No newline at end of file | ||
diff --git a/bin/Release/Grid.ini b/bin/Release/Grid.ini deleted file mode 100644 index ef922b1..0000000 --- a/bin/Release/Grid.ini +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | <Root> | ||
2 | <Grid> | ||
3 | <Region Name="Test Sandbox" ImageID="00000000-0000-0000-7009-000000000008" IP_Address="127.0.0.1" IP_Port="1000" Location_X="997" Location_Y="996" /> | ||
4 | <CurrentRegion RegionHandle="1096213093147648" LoginServer="true" /> | ||
5 | </Grid> | ||
6 | </Root> \ No newline at end of file | ||
diff --git a/bin/Release/new-login.dat b/bin/Release/new-login.dat deleted file mode 100644 index 4833533..0000000 --- a/bin/Release/new-login.dat +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?><methodResponse><params><param><value><struct><member><name>message</name><value><string>Welcome to OpenSim</string></value></member><member><name>session_id</name><value><string>99998888-8520-4f52-8ec1-0b1d5cd6aead</string></value></member><member><name>inventory-skel-lib</name><value><array><data /></array></value></member><member><name>sim_port</name><value><i4>1000</i4></value></member><member><name>agent_access</name><value><string>M</string></value></member><member><name>event_notifications</name><value><array><data /></array></value></member><member><name>start_location</name><value><string>last</string></value></member><member><name>global-textures</name><value><array><data><value><struct><member><name>sun_texture_id</name><value><string>cce0f112-878f-4586-a2e2-a8f104bba271</string></value></member><member><name>cloud_texture_id</name><value><string>fc4b9f0b-d008-45c6-96a4-01dd947ac621</string></value></member><member><name>moon_texture_id</name><value><string>d07f6eed-b96a-47cd-b51d-400ad4a1c428</string></value></member></struct></value></data></array></value></member><member><name>seconds_since_epoch</name><value><i4>1169908672</i4></value></member><member><name>first_name</name><value><string>"Test"</string></value></member><member><name>circuit_code</name><value><i4>50633318</i4></value></member><member><name>event_categories</name><value><array><data /></array></value></member><member><name>login-flags</name><value><array><data><value><struct><member><name>stipend_since_login</name><value><string>N</string></value></member><member><name>ever_logged_in</name><value><string>Y</string></value></member><member><name>gendered</name><value><string>Y</string></value></member><member><name>daylight_savings</name><value><string>N</string></value></member></struct></value></data></array></value></member><member><name>seed_capability</name><value /></member><member><name>home</name><value><string>{'region_handle':[r258560, r259840], 'position':[r41.6589, r100.8374, r22.5072], 'look_at':[r-0.57343, r-0.819255,r0]}</string></value></member><member><name>secure_session_id</name><value><string>71810f75-7437-49fb-8963-02b8fd1b95bf</string></value></member><member><name>last_name</name><value><string>User</string></value></member><member><name>ui-config</name><value><array><data><value><struct><member><name>allow_first_life</name><value><string>Y</string></value></member></struct></value></data></array></value></member><member><name>classified_categories</name><value><array><data><value><struct><member><name>category_name</name><value><string>Shopping</string></value></member><member><name>category_id</name><value><i4>1</i4></value></member></struct></value><value><struct><member><name>category_name</name><value><string>Land Rental</string></value></member><member><name>category_id</name><value><i4>2</i4></value></member></struct></value><value><struct><member><name>category_name</name><value><string>Property Rental</string></value></member><member><name>category_id</name><value><i4>3</i4></value></member></struct></value><value><struct><member><name>category_name</name><value><string>Special Attraction</string></value></member><member><name>category_id</name><value><i4>4</i4></value></member></struct></value><value><struct><member><name>category_name</name><value><string>New Products</string></value></member><member><name>category_id</name><value><i4>5</i4></value></member></struct></value><value><struct><member><name>category_name</name><value><string>Employment</string></value></member><member><name>category_id</name><value><i4>6</i4></value></member></struct></value><value><struct><member><name>category_name</name><value><string>Wanted</string></value></member><member><name>category_id</name><value><i4>7</i4></value></member></struct></value><value><struct><member><name>category_name</name><value><string>Service</string></value></member><member><name>category_id</name><value><i4>8</i4></value></member></struct></value><value><struct><member><name>category_name</name><value><string>Personal</string></value></member><member><name>category_id</name><value><i4>9</i4></value></member></struct></value></data></array></value></member><member><name>region_x</name><value><i4>255232</i4></value></member><member><name>inventory-skeleton</name><value><array><data><value><struct><member><name>name</name><value><string>My Inventory</string></value></member><member><name>parent_id</name><value><string>00000000-0000-0000-0000-000000000000</string></value></member><member><name>version</name><value><i4>4</i4></value></member><member><name>type_default</name><value><i4>8</i4></value></member><member><name>folder_id</name><value><string>f798e114-c10f-409b-a90d-a11577ff1de8</string></value></member></struct></value><value><struct><member><name>name</name><value><string>Textures</string></value></member><member><name>parent_id</name><value><string>f798e114-c10f-409b-a90d-a11577ff1de8</string></value></member><member><name>version</name><value><i4>1</i4></value></member><member><name>type_default</name><value><i4>0</i4></value></member><member><name>folder_id</name><value><string>fc8b4059-30bb-43a8-a042-46f5b431ad82</string></value></member></struct></value></data></array></value></member><member><name>sim_ip</name><value><string>127.0.0.1</string></value></member><member><name>region_y</name><value><i4>254976</i4></value></member><member><name>gestures</name><value><array><data /></array></value></member><member><name>inventory-lib-owner</name><value><array><data /></array></value></member><member><name>inventory-root</name><value><array><data><value><struct><member><name>folder_id</name><value><string>f798e114-c10f-409b-a90d-a11577ff1de8</string></value></member></struct></value></data></array></value></member><member><name>login</name><value><string>true</string></value></member><member><name>look_at</name><value><string>[r0.99949799999999999756,r0.03166859999999999814,r0]</string></value></member><member><name>agent_id</name><value><string>aaaabbbb-8932-0271-8664-58f53e442797</string></value></member><member><name>inventory-lib-root</name><value><array><data /></array></value></member><member><name>initial-outfit</name><value><array><data><value><struct><member><name>folder_name</name><value><string>Nightclub Female</string></value></member><member><name>gender</name><value><string>female</string></value></member></struct></value></data></array></value></member></struct></value></param></params></methodResponse> | ||
2 | end-mfile \ No newline at end of file | ||
diff --git a/bin/Release/textures/map1.jp2 b/bin/Release/textures/map1.jp2 deleted file mode 100644 index cd2fd94..0000000 --- a/bin/Release/textures/map1.jp2 +++ /dev/null | |||
Binary files differ | |||
diff --git a/bin/Release/textures/map_base.jp2 b/bin/Release/textures/map_base.jp2 deleted file mode 100644 index 5ad1fd0..0000000 --- a/bin/Release/textures/map_base.jp2 +++ /dev/null | |||
Binary files differ | |||
diff --git a/lib/Axiom.MathLib.dll b/lib/Axiom.MathLib.dll deleted file mode 100644 index 21ce3a8..0000000 --- a/lib/Axiom.MathLib.dll +++ /dev/null | |||
Binary files differ | |||
diff --git a/lib/log4net.dll b/lib/log4net.dll deleted file mode 100644 index ffc57e1..0000000 --- a/lib/log4net.dll +++ /dev/null | |||
Binary files differ | |||