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 /Controller.cs | |
parent | Patch Applied regarding Bug #51 (diff) | |
download | opensim-SC_OLD-5453580d550e96cdeeec855d610082c662562022.zip opensim-SC_OLD-5453580d550e96cdeeec855d610082c662562022.tar.gz opensim-SC_OLD-5453580d550e96cdeeec855d610082c662562022.tar.bz2 opensim-SC_OLD-5453580d550e96cdeeec855d610082c662562022.tar.xz |
Removed old trunk code
Diffstat (limited to '')
-rw-r--r-- | Controller.cs | 358 |
1 files changed, 0 insertions, 358 deletions
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 | } | ||