diff options
Diffstat (limited to '')
-rw-r--r-- | Main-sever.cs | 270 |
1 files changed, 0 insertions, 270 deletions
diff --git a/Main-sever.cs b/Main-sever.cs deleted file mode 100644 index 911d9d7..0000000 --- a/Main-sever.cs +++ /dev/null | |||
@@ -1,270 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2007 Michael Wright | ||
3 | |||
4 | * Copyright (c) <year>, <copyright holder> | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions are met: | ||
9 | * * Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * * Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * * Neither the name of the <organization> nor the | ||
15 | * names of its contributors may be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
19 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
21 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | using System; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Drawing; | ||
33 | using System.Windows.Forms; | ||
34 | using libsecondlife; | ||
35 | using libsecondlife.Packets; | ||
36 | using System.Collections; | ||
37 | using System.Text; | ||
38 | using System.IO; | ||
39 | using Axiom.MathLib; | ||
40 | |||
41 | namespace Second_server | ||
42 | { | ||
43 | /// <summary> | ||
44 | /// Description of MainForm. | ||
45 | /// </summary> | ||
46 | public partial class Main_server:Server_callback | ||
47 | { | ||
48 | |||
49 | [STAThread] | ||
50 | public static void Main(string[] args) | ||
51 | { | ||
52 | Application.EnableVisualStyles(); | ||
53 | Application.SetCompatibleTextRenderingDefault(false); | ||
54 | Application.Run(new Main_server()); | ||
55 | } | ||
56 | public Server server; | ||
57 | |||
58 | //public bool intin=false; | ||
59 | //private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock avatar_template; | ||
60 | //private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock object_template; | ||
61 | |||
62 | private Agent_Manager agent_man; | ||
63 | private Prim_manager prim_man; | ||
64 | private Texture_manager texture_man; | ||
65 | private Asset_manager asset_man; | ||
66 | private Login_manager login_man; //built in login server | ||
67 | private ulong time; //ticks | ||
68 | |||
69 | public Main_server() | ||
70 | { | ||
71 | // | ||
72 | // The InitializeComponent() call is required for Windows Forms designer support. | ||
73 | // | ||
74 | InitializeComponent(); | ||
75 | |||
76 | // | ||
77 | // TODO: Add constructor code after the InitializeComponent() call. | ||
78 | // | ||
79 | |||
80 | server=new Server(this); | ||
81 | agent_man=new Agent_Manager(this.server); | ||
82 | prim_man=new Prim_manager(this.server); | ||
83 | texture_man=new Texture_manager(this.server); | ||
84 | asset_man=new Asset_manager(this.server); | ||
85 | prim_man.agent_man=agent_man; | ||
86 | agent_man.prim_man=prim_man; | ||
87 | login_man=new Login_manager(); // startup | ||
88 | login_man.startup(); // login server | ||
89 | |||
90 | } | ||
91 | public void main_callback(Packet pack, User_Agent_info User_info) | ||
92 | { | ||
93 | if((pack.Type!= PacketType.StartPingCheck) && (pack.Type!= PacketType.AgentUpdate)) | ||
94 | { | ||
95 | //System.Console.WriteLine(pack.Type); | ||
96 | //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; | ||
97 | } | ||
98 | if(pack.Type== PacketType.AgentSetAppearance) | ||
99 | { | ||
100 | //System.Console.WriteLine(pack); | ||
101 | //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; | ||
102 | |||
103 | } | ||
104 | if(pack.Type== PacketType.TransferRequest) | ||
105 | { | ||
106 | TransferRequestPacket tran=(TransferRequestPacket)pack; | ||
107 | LLUUID id=new LLUUID(tran.TransferInfo.Params,0); | ||
108 | |||
109 | if((id==new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73")) ||(id==new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"))) | ||
110 | { | ||
111 | //System.Console.WriteLine(pack); | ||
112 | //System.Console.WriteLine(tran.TransferInfo.TransferID); | ||
113 | asset_man.add_request(User_info,id,tran); | ||
114 | //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; | ||
115 | } | ||
116 | |||
117 | } | ||
118 | if((pack.Type== PacketType.StartPingCheck) ) | ||
119 | { | ||
120 | //reply to pingcheck | ||
121 | libsecondlife.Packets.StartPingCheckPacket startp=(libsecondlife.Packets.StartPingCheckPacket)pack; | ||
122 | libsecondlife.Packets.CompletePingCheckPacket endping=new CompletePingCheckPacket(); | ||
123 | endping.PingID.PingID=startp.PingID.PingID; | ||
124 | server.SendPacket(endping,true,User_info); | ||
125 | } | ||
126 | if(pack.Type==PacketType.CompleteAgentMovement) | ||
127 | { | ||
128 | // new client | ||
129 | agent_man.Agent_join(User_info); | ||
130 | } | ||
131 | if (pack.Type==PacketType.RequestImage) | ||
132 | { | ||
133 | RequestImagePacket image_req=(RequestImagePacket)pack; | ||
134 | for(int i=0; i<image_req.RequestImage.Length ;i++) | ||
135 | { | ||
136 | this.texture_man.add_request(User_info,image_req.RequestImage[i].Image); | ||
137 | |||
138 | } | ||
139 | } | ||
140 | if (pack.Type==PacketType.RegionHandshakeReply) | ||
141 | { | ||
142 | //recieved regionhandshake so can now start sending info | ||
143 | agent_man.send_intial_data(User_info); | ||
144 | //this.setuptemplates("objectupate164.dat",User_info,false); | ||
145 | } | ||
146 | if(pack.Type== PacketType.ObjectAdd) | ||
147 | { | ||
148 | ObjectAddPacket ad=(ObjectAddPacket)pack; | ||
149 | prim_man.create_prim(User_info,ad.ObjectData.RayEnd, ad); | ||
150 | //this.send_prim(User_info,ad.ObjectData.RayEnd, ad); | ||
151 | } | ||
152 | if(pack.Type== PacketType.ObjectPosition) | ||
153 | { | ||
154 | //System.Console.WriteLine(pack.ToString()); | ||
155 | } | ||
156 | if(pack.Type== PacketType.MultipleObjectUpdate) | ||
157 | { | ||
158 | //System.Console.WriteLine(pack.ToString()); | ||
159 | MultipleObjectUpdatePacket mupd=(MultipleObjectUpdatePacket)pack; | ||
160 | |||
161 | for(int i=0; i<mupd.ObjectData.Length; i++) | ||
162 | { | ||
163 | if(mupd.ObjectData[i].Type==9) //change position | ||
164 | { | ||
165 | libsecondlife.LLVector3 pos=new LLVector3(mupd.ObjectData[i].Data, 0); | ||
166 | |||
167 | prim_man.update_prim_position(User_info, pos.X,pos.Y,pos.Z,mupd.ObjectData[i].ObjectLocalID); | ||
168 | //should update stored position of the prim | ||
169 | } | ||
170 | } | ||
171 | } | ||
172 | if(pack.Type== PacketType.AgentWearablesRequest) | ||
173 | { | ||
174 | agent_man.send_intial_avatar_apper(User_info); | ||
175 | } | ||
176 | |||
177 | if(pack.Type==PacketType.AgentUpdate) | ||
178 | { | ||
179 | AgentUpdatePacket ag=(AgentUpdatePacket)pack; | ||
180 | uint mask=ag.AgentData.ControlFlags&(1); | ||
181 | Avatar_data m_av=agent_man.Get_Agent(User_info.AgentID); | ||
182 | if(m_av!=null) | ||
183 | { | ||
184 | if(m_av.started) | ||
185 | { | ||
186 | if(mask==(1)) | ||
187 | { | ||
188 | if(!m_av.walk) | ||
189 | { | ||
190 | //start walking | ||
191 | agent_man.send_move_command(User_info,false,m_av.pos.X,m_av.pos.Y,m_av.pos.Z,0,ag.AgentData.BodyRotation); | ||
192 | Axiom.MathLib.Vector3 v3=new Axiom.MathLib.Vector3(1,0,0); | ||
193 | Axiom.MathLib.Quaternion q=new Axiom.MathLib.Quaternion(ag.AgentData.BodyRotation.W,ag.AgentData.BodyRotation.X,ag.AgentData.BodyRotation.Y,ag.AgentData.BodyRotation.Z); | ||
194 | Axiom.MathLib.Vector3 direc=q*v3; | ||
195 | direc.Normalize(); | ||
196 | direc=direc*((0.03f)*128f); | ||
197 | |||
198 | m_av.vel.X=direc.x; | ||
199 | m_av.vel.Y=direc.y; | ||
200 | m_av.vel.Z=direc.z; | ||
201 | m_av.walk=true; | ||
202 | } | ||
203 | } | ||
204 | else{ | ||
205 | if(m_av.walk) | ||
206 | { | ||
207 | //walking but key not pressed so need to stop | ||
208 | agent_man.send_move_command(User_info,true,m_av.pos.X,m_av.pos.Y,m_av.pos.Z,0,ag.AgentData.BodyRotation); | ||
209 | m_av.walk=false; | ||
210 | m_av.vel.X=0; | ||
211 | m_av.vel.Y=0; | ||
212 | m_av.vel.Z=0; | ||
213 | } | ||
214 | } | ||
215 | }} | ||
216 | } | ||
217 | |||
218 | if(pack.Type==PacketType.ChatFromViewer) | ||
219 | { | ||
220 | ChatFromViewerPacket chat=(ChatFromViewerPacket)pack; | ||
221 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
222 | |||
223 | string myString = enc.GetString(chat.ChatData.Message ); | ||
224 | if(myString!="") | ||
225 | { | ||
226 | string [] comp= new string[10]; | ||
227 | string delimStr = " , "; | ||
228 | char [] delimiter = delimStr.ToCharArray(); | ||
229 | string line; | ||
230 | |||
231 | line=myString; | ||
232 | comp=line.Split(delimiter); | ||
233 | if(comp[0]=="pos") | ||
234 | { | ||
235 | } | ||
236 | else if(comp[0]=="veloc") | ||
237 | { | ||
238 | } | ||
239 | else | ||
240 | { | ||
241 | agent_man.send_chat_message(User_info,line); | ||
242 | |||
243 | } | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | public void new_user(User_Agent_info User_info) | ||
248 | { | ||
249 | this.richTextBox1.Text=this.richTextBox1.Text+"\n "+"new user - "+User_info.AgentID.ToString()+" - has joined"; | ||
250 | this.richTextBox1.Text=this.richTextBox1.Text+"\n "+"session id := "+User_info.SessionID.ToString(); | ||
251 | agent_man.New_Agent(User_info); | ||
252 | |||
253 | } | ||
254 | |||
255 | public void error(string text) | ||
256 | { | ||
257 | this.richTextBox1.Text=this.richTextBox1.Text+"\n error report: "+text; | ||
258 | } | ||
259 | |||
260 | void Timer1Tick(object sender, System.EventArgs e) | ||
261 | { | ||
262 | this.time++; | ||
263 | agent_man.tick(); | ||
264 | texture_man.Do_work(time); | ||
265 | } | ||
266 | |||
267 | |||
268 | } | ||
269 | |||
270 | } | ||