aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Controller.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Controller.cs228
1 files changed, 109 insertions, 119 deletions
diff --git a/Controller.cs b/Controller.cs
index 3ace638..6282ce3 100644
--- a/Controller.cs
+++ b/Controller.cs
@@ -43,47 +43,46 @@ namespace OpenSim
43 /// <summary> 43 /// <summary>
44 /// Description of MainForm. 44 /// Description of MainForm.
45 /// </summary> 45 /// </summary>
46 public partial class Controller : ServerCallback { 46 public partial class Controller : ServerCallback
47 47 {
48
49 48
50 [STAThread] 49 [STAThread]
51 public static void Main( string[] args ) { 50 public static void Main( string[] args )
51 {
52 Controller c = new Controller(); 52 Controller c = new Controller();
53 while( true ) // fuckin' a 53 while( true ) // fuckin' a
54 System.Threading.Thread.Sleep( 1000 ); 54 System.Threading.Thread.Sleep( 1000 );
55
56 } 55 }
57 public Server server; 56
58 public Logon _login; 57 private Server _server;
59 private AgentManager Agent_Manager; 58 private Logon _login;
60 private PrimManager Prim_Manager; 59 private AgentManager _agentManager;
61 private AssetManagement Asset_Manager; 60 private PrimManager _primManager;
62 private GridManager Grid_Manager; 61 private AssetManagement _assetManager;
63 private InventoryManager Inventory_Manager; 62 private GridManager _gridManager;
64 private LoginManager Login_Manager; //built in login server 63 private InventoryManager _inventoryManager;
64 private LoginManager _loginManager; //built in login server
65 private ulong time; //ticks 65 private ulong time; //ticks
66 private Timer timer1 = new Timer(); 66 private Timer timer1 = new Timer();
67 67
68 68
69 public Controller() { 69 public Controller() {
70 _login=new Logon(); // should create a list for these. 70 _login = new Logon(); // should create a list for these.
71 server = new Server( this ); 71 _server = new Server( this );
72 Agent_Manager = new AgentManager( this.server ); 72 _agentManager = new AgentManager( this._server );
73 Prim_Manager = new PrimManager( this.server ); 73 _primManager = new PrimManager( this._server );
74 Asset_Manager = new AssetManagement( this.server ); 74 _inventoryManager = new InventoryManager(this._server);
75 Prim_Manager.Agent_Manager = Agent_Manager; 75 _assetManager = new AssetManagement(this._server, _inventoryManager );
76 Agent_Manager.Prim_Manager = Prim_Manager; 76 _primManager.AgentManagement = _agentManager;
77 Agent_Manager.Asset_Manager=Asset_Manager; 77 _agentManager.Prim_Manager = _primManager;
78 Inventory_Manager=new InventoryManager(this.server); 78 _agentManager.assetManager = _assetManager;
79 Asset_Manager.InventoryManager=Inventory_Manager; 79 _gridManager = new GridManager(this._server, _agentManager);
80 Grid_Manager=new GridManager(this.server,Agent_Manager);
81 80
82 if(Globals.Instance.LoginSever) 81 if(Globals.Instance.LoginSever)
83 { 82 {
84 Console.WriteLine("Starting login Server"); 83 Console.WriteLine("Starting login Server");
85 Login_Manager = new LoginManager(_login); // startup 84 _loginManager = new LoginManager(_login); // startup
86 Login_Manager.Startup(); // login server 85 _loginManager.Startup(); // login server
87 } 86 }
88 87
89 timer1.Enabled = true; 88 timer1.Enabled = true;
@@ -92,169 +91,162 @@ namespace OpenSim
92 91
93 92
94 } 93 }
95 public void MainCallback( Packet pack, User_Agent_info User_info ) { 94 public void MainCallback( Packet pack, UserAgentInfo userInfo )
95 {
96 96
97 /*if( ( pack.Type != PacketType.StartPingCheck ) && ( pack.Type != PacketType.AgentUpdate ) ) { 97 /*if( ( pack.Type != PacketType.StartPingCheck ) && ( pack.Type != PacketType.AgentUpdate ) ) {
98 //Log packet? 98 //Log packet?
99 // System.Console.WriteLine(pack.Type); 99 //System.Console.WriteLine(pack.Type);
100 //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; 100 //this.richTextBox1.Text = this.richTextBox1.Text + "\n " + pack.Type;
101 }*/ 101 }*/
102 102
103 //should replace with a switch 103 //should replace with a switch
104 if( pack.Type == PacketType.AgentSetAppearance ) { 104 if( pack.Type == PacketType.AgentSetAppearance ) {
105 //System.Console.WriteLine(pack); 105
106 //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type;
107
108 } 106 }
109 else if( pack.Type == PacketType.FetchInventory) 107 else if( pack.Type == PacketType.FetchInventory)
110 { 108 {
111 FetchInventoryPacket FetchInventory=(FetchInventoryPacket)pack; 109 FetchInventoryPacket FetchInventory = (FetchInventoryPacket)pack;
112 Inventory_Manager.FetchInventory(User_info,FetchInventory); 110 _inventoryManager.FetchInventory(userInfo, FetchInventory);
113 } 111 }
114 else if( pack.Type == PacketType.FetchInventoryDescendents) 112 else if( pack.Type == PacketType.FetchInventoryDescendents)
115 { 113 {
116 FetchInventoryDescendentsPacket Fetch=(FetchInventoryDescendentsPacket)pack; 114 FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)pack;
117 Inventory_Manager.FetchInventoryDescendents(User_info,Fetch); 115 _inventoryManager.FetchInventoryDescendents(userInfo, Fetch);
118 } 116 }
119 else if(pack.Type== PacketType.MapBlockRequest) 117 else if(pack.Type == PacketType.MapBlockRequest)
120 { 118 {
121 //int MinX, MinY, MaxX, MaxY;
122 MapBlockRequestPacket MapRequest=(MapBlockRequestPacket)pack; 119 MapBlockRequestPacket MapRequest=(MapBlockRequestPacket)pack;
123 this.Grid_Manager.RequestMapBlock(User_info,MapRequest.PositionData.MinX,MapRequest.PositionData.MinY,MapRequest.PositionData.MaxX,MapRequest.PositionData.MaxY); 120 this._gridManager.RequestMapBlock(userInfo, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY);
124 121
125 } 122 }
126 else if(pack.Type== PacketType.CloseCircuit) 123 else if(pack.Type == PacketType.CloseCircuit)
127 { 124 {
128 this.Agent_Manager.RemoveAgent(User_info); 125 this._agentManager.RemoveAgent(userInfo);
129 } 126 }
130 else if(pack.Type== PacketType.MapLayerRequest) 127 else if(pack.Type == PacketType.MapLayerRequest)
131 { 128 {
132 this.Grid_Manager.RequestMapLayer(User_info); 129 this._gridManager.RequestMapLayer(userInfo);
133
134 } 130 }
135 else if((pack.Type== PacketType.TeleportRequest ) ||(pack.Type== PacketType.TeleportLocationRequest)) 131 else if((pack.Type == PacketType.TeleportRequest ) || (pack.Type == PacketType.TeleportLocationRequest))
136 { 132 {
137 TeleportLocationRequestPacket Request=(TeleportLocationRequestPacket)pack; 133 TeleportLocationRequestPacket Request = (TeleportLocationRequestPacket)pack;
138 134 this._gridManager.RequestTeleport(userInfo,Request);
139 this.Grid_Manager.RequestTeleport(User_info,Request);
140 135
141 } 136 }
142 else if( pack.Type == PacketType.TransferRequest ) { 137 else if( pack.Type == PacketType.TransferRequest ) {
143 TransferRequestPacket tran = (TransferRequestPacket)pack; 138 TransferRequestPacket transfer = (TransferRequestPacket)pack;
144 LLUUID id = new LLUUID( tran.TransferInfo.Params, 0 ); 139 LLUUID id = new LLUUID( transfer.TransferInfo.Params, 0 );
145 Asset_Manager.AddAssetRequest( User_info, id, tran ); 140 _assetManager.AddAssetRequest( userInfo, id, transfer );
146
147 } 141 }
148 else if( ( pack.Type == PacketType.StartPingCheck ) ) { 142 else if( ( pack.Type == PacketType.StartPingCheck ) ) {
149 //reply to pingcheck 143 //reply to pingcheck
150 libsecondlife.Packets.StartPingCheckPacket startp = (libsecondlife.Packets.StartPingCheckPacket)pack; 144 libsecondlife.Packets.StartPingCheckPacket startping = (libsecondlife.Packets.StartPingCheckPacket)pack;
151 libsecondlife.Packets.CompletePingCheckPacket endping = new CompletePingCheckPacket(); 145 libsecondlife.Packets.CompletePingCheckPacket endping = new CompletePingCheckPacket();
152 endping.PingID.PingID = startp.PingID.PingID; 146 endping.PingID.PingID = startping.PingID.PingID;
153 server.SendPacket( endping, true, User_info ); 147 _server.SendPacket(endping, true, userInfo );
154 } 148 }
155 else if( pack.Type == PacketType.CompleteAgentMovement ) 149 else if( pack.Type == PacketType.CompleteAgentMovement )
156 { 150 {
157 // new client 151 _agentManager.AgentJoin(userInfo );
158 Agent_Manager.AgentJoin( User_info );
159 } 152 }
160 else if( pack.Type == PacketType.RequestImage ) 153 else if( pack.Type == PacketType.RequestImage )
161 { 154 {
162 RequestImagePacket image_req = (RequestImagePacket)pack; 155 RequestImagePacket imageRequest = (RequestImagePacket)pack;
163 for( int i = 0; i < image_req.RequestImage.Length; i++ ) 156 for( int i = 0; i < imageRequest.RequestImage.Length; i++ )
164 { 157 {
165 this.Asset_Manager.AddTextureRequest( User_info, image_req.RequestImage[ i ].Image ); 158 this._assetManager.AddTextureRequest(userInfo, imageRequest.RequestImage[i].Image);
166 } 159 }
167 } 160 }
168 else if( pack.Type == PacketType.RegionHandshakeReply ) { 161 else if( pack.Type == PacketType.RegionHandshakeReply ) {
169 //recieved regionhandshake so can now start sending info 162 //recieved regionhandshake so can now start sending info
170 Agent_Manager.SendInitialData( User_info ); 163 _agentManager.SendInitialData(userInfo );
171 //this.setuptemplates("objectupate164.dat",User_info,false); 164 }
172 }
173 else if( pack.Type == PacketType.ObjectAdd ) 165 else if( pack.Type == PacketType.ObjectAdd )
174 { 166 {
175 ObjectAddPacket ad = (ObjectAddPacket)pack; 167 ObjectAddPacket ad = (ObjectAddPacket)pack;
176 Prim_Manager.CreatePrim( User_info, ad.ObjectData.RayEnd, ad ); 168 _primManager.CreatePrim(userInfo, ad.ObjectData.RayEnd, ad );
177 //this.send_prim(User_info,ad.ObjectData.RayEnd, ad);
178 } 169 }
179 else if( pack.Type == PacketType.ObjectPosition ) { 170 else if( pack.Type == PacketType.ObjectPosition ) {
180 //System.Console.WriteLine(pack.ToString()); 171 //System.Console.WriteLine(pack.ToString());
181 } 172 }
182 else if( pack.Type == PacketType.MultipleObjectUpdate ) { 173 else if( pack.Type == PacketType.MultipleObjectUpdate )
183 //System.Console.WriteLine(pack.ToString()); 174 {
184 MultipleObjectUpdatePacket mupd = (MultipleObjectUpdatePacket)pack; 175 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)pack;
185 176
186 for( int i = 0; i < mupd.ObjectData.Length; i++ ) 177 for( int i = 0; i < multipleupdate.ObjectData.Length; i++ )
187 { 178 {
188 if( mupd.ObjectData[ i ].Type == 9 ) //change position 179 if( multipleupdate.ObjectData[ i ].Type == 9 ) //change position
189 { 180 {
190 libsecondlife.LLVector3 pos = new LLVector3( mupd.ObjectData[ i ].Data, 0 ); 181 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[ i ].Data, 0 );
191 // libsecondlife.LLQuaternion rot=new LLQuaternion(mupd.ObjectData[i].Data,12,true); 182 _primManager.UpdatePrimPosition(userInfo, pos, multipleupdate.ObjectData[ i ].ObjectLocalID ,false ,libsecondlife.LLQuaternion.Identity);
192 Prim_Manager.UpdatePrimPosition( User_info, pos, mupd.ObjectData[ i ].ObjectLocalID ,false ,libsecondlife.LLQuaternion.Identity);
193 //should update stored position of the prim 183 //should update stored position of the prim
194 } 184 }
195 else if( mupd.ObjectData[ i ].Type == 10 ) 185 else if(multipleupdate.ObjectData[i].Type == 10 )//rotation
196 { 186 {
197 //System.Console.WriteLine(mupd.ObjectData[ i ].Type);
198 //System.Console.WriteLine(mupd);
199 libsecondlife.LLVector3 pos = new LLVector3(100,100,22); 187 libsecondlife.LLVector3 pos = new LLVector3(100,100,22);
200 libsecondlife.LLQuaternion rot=new LLQuaternion(mupd.ObjectData[i].Data,0,true); 188 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
201 Prim_Manager.UpdatePrimPosition( User_info, pos, mupd.ObjectData[ i ].ObjectLocalID ,true ,rot); 189 _primManager.UpdatePrimPosition(userInfo, pos, multipleupdate.ObjectData[ i ].ObjectLocalID, true ,rot);
202
203 } 190 }
204 } 191 }
205 } 192 }
206 else if( pack.Type == PacketType.AgentWearablesRequest ) 193 else if( pack.Type == PacketType.AgentWearablesRequest )
207 { 194 {
208 Agent_Manager.SendIntialAvatarAppearance( User_info ); 195 _agentManager.SendIntialAvatarAppearance(userInfo );
209 } 196 }
210 else if( pack.Type == PacketType.AgentUpdate ) 197 else if(pack.Type == PacketType.AgentUpdate)
211 { 198 {
212 AgentUpdatePacket ag = (AgentUpdatePacket)pack; 199 // System.Console.WriteLine("agent update");
213 uint mask = ag.AgentData.ControlFlags & ( 1 ); 200 AgentUpdatePacket agent = (AgentUpdatePacket)pack;
214 AvatarData m_av = Agent_Manager.GetAgent( User_info.AgentID ); 201 uint mask = agent.AgentData.ControlFlags & ( 1 );
215 if( m_av != null ) 202 AvatarData avatar = _agentManager.GetAgent(userInfo.AgentID );
216 { 203 if(avatar != null )
217 if( m_av.Started ) 204 {
205 if(avatar.Started )
218 { 206 {
219 if( mask == ( 1 ) ) 207 if( mask == ( 1 ) )
220 { 208 {
221 if( !m_av.Walk ) 209 if(!avatar.Walk)
222 { 210 {
223 //start walking 211 //start walking
224 Agent_Manager.SendMoveCommand( User_info, false, m_av.Position.X, m_av.Position.Y, m_av.Position.Z, 0, ag.AgentData.BodyRotation ); 212 _agentManager.SendMoveCommand(userInfo, false, avatar.Position.X, avatar.Position.Y, avatar.Position.Z, 0, agent.AgentData.BodyRotation );
225 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3( 1, 0, 0 ); 213 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3( 1, 0, 0 );
226 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion( ag.AgentData.BodyRotation.W, ag.AgentData.BodyRotation.X, ag.AgentData.BodyRotation.Y, ag.AgentData.BodyRotation.Z ); 214 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion( agent.AgentData.BodyRotation.W, agent.AgentData.BodyRotation.X, agent.AgentData.BodyRotation.Y, agent.AgentData.BodyRotation.Z );
227 Axiom.MathLib.Vector3 direc = q * v3; 215 Axiom.MathLib.Vector3 direc = q * v3;
228 direc.Normalize(); 216 direc.Normalize();
229 direc = direc * ( ( 0.03f ) * 128f ); 217 direc = direc * ( ( 0.03f ) * 128f );
230 218
231 m_av.Velocity.X = direc.x; 219 avatar.Velocity.X = direc.x;
232 m_av.Velocity.Y = direc.y; 220 avatar.Velocity.Y = direc.y;
233 m_av.Velocity.Z = direc.z; 221 avatar.Velocity.Z = direc.z;
234 m_av.Walk = true; 222 avatar.Walk = true;
235 } 223 }
236 } 224 }
237 else 225 else
238 { 226 {
239 if( m_av.Walk ) 227 if(avatar.Walk)
240 { 228 {
241 //walking but key not pressed so need to stop 229 //walking but key not pressed so need to stop
242 Agent_Manager.SendMoveCommand( User_info, true, m_av.Position.X, m_av.Position.Y, m_av.Position.Z, 0, ag.AgentData.BodyRotation ); 230 _agentManager.SendMoveCommand(userInfo, true, avatar.Position.X, avatar.Position.Y, avatar.Position.Z, 0, agent.AgentData.BodyRotation );
243 m_av.Walk = false; 231 avatar.Walk = false;
244 m_av.Velocity.X = 0; 232 avatar.Velocity.X = 0;
245 m_av.Velocity.Y = 0; 233 avatar.Velocity.Y = 0;
246 m_av.Velocity.Z = 0; 234 avatar.Velocity.Z = 0;
247 } 235 }
248 } 236 }
249 } 237 }
250 } 238 }
239 else
240 {
241
242 }
251 } 243 }
252 else if( pack.Type == PacketType.ChatFromViewer ) 244 else if( pack.Type == PacketType.ChatFromViewer )
253 { 245 {
254 ChatFromViewerPacket chat = (ChatFromViewerPacket)pack; 246 ChatFromViewerPacket chat = (ChatFromViewerPacket)pack;
255 System.Text.Encoding enc = System.Text.Encoding.ASCII; 247 System.Text.Encoding enc = System.Text.Encoding.ASCII;
256 248
257 string myString = enc.GetString( chat.ChatData.Message ); 249 string myString = enc.GetString(chat.ChatData.Message );
258 if( myString != "" ) { 250 if( myString != "" ) {
259 string[] comp = new string[ 10 ]; 251 string[] comp = new string[ 10 ];
260 string delimStr = " , "; 252 string delimStr = " , ";
@@ -271,34 +263,32 @@ namespace OpenSim
271 } 263 }
272 else 264 else
273 { 265 {
274 Agent_Manager.SendChatMessage( User_info, line ); 266 _agentManager.SendChatMessage(userInfo, line );
275
276 } 267 }
277 } 268 }
278 } 269 }
279 } 270 }
280 public void NewUserCallback( User_Agent_info UserInfo ) 271 public void NewUserCallback(UserAgentInfo userInfo )
281 { 272 {
282 Console.WriteLine( "new user - {0} - has joined [session {1}]", UserInfo.AgentID.ToString(), UserInfo.SessionID.ToString() +"curcuit used"+UserInfo.circuitCode); 273 Console.WriteLine( "new user - {0} - has joined [session {1}]", userInfo.AgentID.ToString(), userInfo.SessionID.ToString() +"curcuit used"+userInfo.circuitCode);
283 string first,last; 274 string first,last;
284 LLUUID Base,Inventory; 275 LLUUID Base,Inventory;
285 lock(_login) 276 lock(_login)
286 { 277 {
287 first=_login.first; 278 first=_login.First;
288 last=_login.last; 279 last=_login.Last;
289 Base=_login.BaseFolder; 280 Base=_login.BaseFolder;
290 Inventory=_login.InventoryFolder; 281 Inventory=_login.InventoryFolder;
291
292 //should get agentid and sessionid so they can be checked. 282 //should get agentid and sessionid so they can be checked.
293 } 283 }
294 Agent_Manager.NewAgent( UserInfo ,first,last,Base,Inventory); 284 _agentManager.NewAgent(userInfo, first, last, Base, Inventory);
295 //now because of the lack of Global account management (User server etc) 285 //now because of the lack of Global account management (User server etc)
296 //we need to reset the names back to default incase a teleport happens 286 //we need to reset the names back to default incase a teleport happens
297 //which will not have a Login name set, so they will use default names 287 //which will not have a Login name set, so they will use default names
298 lock(_login) 288 lock(_login)
299 { 289 {
300 _login.first="Test"; 290 _login.First="Test";
301 _login.last="User"; 291 _login.Last="User";
302 } 292 }
303 } 293 }
304 294
@@ -308,14 +298,14 @@ namespace OpenSim
308 298
309 void Timer1Tick( object sender, System.EventArgs e ) { 299 void Timer1Tick( object sender, System.EventArgs e ) {
310 this.time++; 300 this.time++;
311 Agent_Manager.UpdatePositions(); 301 _agentManager.UpdatePositions();
312 this.Asset_Manager.DoWork( time ); 302 this._assetManager.DoWork( time );
313 } 303 }
314 } 304 }
315 public class Logon 305 public class Logon
316 { 306 {
317 public string first="Test"; 307 public string First = "Test";
318 public string last="User"; 308 public string Last = "User";
319 public LLUUID Agent; 309 public LLUUID Agent;
320 public LLUUID Session; 310 public LLUUID Session;
321 public LLUUID InventoryFolder; 311 public LLUUID InventoryFolder;