aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Controller.cs
diff options
context:
space:
mode:
authorMW2007-02-02 17:23:56 +0000
committerMW2007-02-02 17:23:56 +0000
commite75e6f426bfc069e9185c8c72e8707399edfe299 (patch)
tree0700369d4d568eed609709abe0c4442637538218 /Controller.cs
parentClean up (diff)
downloadopensim-SC_OLD-e75e6f426bfc069e9185c8c72e8707399edfe299.zip
opensim-SC_OLD-e75e6f426bfc069e9185c8c72e8707399edfe299.tar.gz
opensim-SC_OLD-e75e6f426bfc069e9185c8c72e8707399edfe299.tar.bz2
opensim-SC_OLD-e75e6f426bfc069e9185c8c72e8707399edfe299.tar.xz
Clean up. Added GridManager and teleport between regions/sims.
Diffstat (limited to '')
-rw-r--r--Controller.cs173
1 files changed, 119 insertions, 54 deletions
diff --git a/Controller.cs b/Controller.cs
index 351ff65..f2bd85c 100644
--- a/Controller.cs
+++ b/Controller.cs
@@ -38,11 +38,12 @@ using System.IO;
38using Axiom.MathLib; 38using Axiom.MathLib;
39using log4net; 39using log4net;
40 40
41namespace Second_server { 41namespace OpenSim
42{
42 /// <summary> 43 /// <summary>
43 /// Description of MainForm. 44 /// Description of MainForm.
44 /// </summary> 45 /// </summary>
45 public partial class Controller : Server_callback { 46 public partial class Controller : ServerCallback {
46 47
47 48
48 49
@@ -54,51 +55,79 @@ namespace Second_server {
54 55
55 } 56 }
56 public Server server; 57 public Server server;
57 58 public Logon _login;
58 private Agent_Manager agent_man; 59 private AgentManager Agent_Manager;
59 private Prim_manager prim_man; 60 private PrimManager Prim_Manager;
60 private Texture_manager texture_man; 61 private TextureManager Texture_Manager;
61 private Asset_manager asset_man; 62 private AssetManager Asset_Manager;
62 private Login_manager login_man; //built in login server 63 private GridManager Grid_Manager;
64 private LoginManager Login_Manager; //built in login server
63 private ulong time; //ticks 65 private ulong time; //ticks
64 private Timer timer1 = new Timer(); 66 private Timer timer1 = new Timer();
65 67
66 68
67 public Controller() { 69 public Controller() {
70 _login=new Logon(); // should create a list for these.
68 server = new Server( this ); 71 server = new Server( this );
69 agent_man = new Agent_Manager( this.server ); 72 Agent_Manager = new AgentManager( this.server );
70 prim_man = new Prim_manager( this.server ); 73 Prim_Manager = new PrimManager( this.server );
71 texture_man = new Texture_manager( this.server ); 74 Texture_Manager = new TextureManager( this.server );
72 asset_man = new Asset_manager( this.server ); 75 Asset_Manager = new AssetManager( this.server );
73 prim_man.agent_man = agent_man; 76 Prim_Manager.Agent_Manager = Agent_Manager;
74 agent_man.prim_man = prim_man; 77 Agent_Manager.Prim_Manager = Prim_Manager;
75 login_man = new Login_manager(); // startup 78 Grid_Manager=new GridManager(this.server,Agent_Manager);
76 login_man.startup(); // login server 79 if(Globals.Instance.LoginSever)
77 timer1.Enabled = true; 80 {
81 Console.WriteLine("Starting login Server");
82 Login_Manager = new LoginManager(_login); // startup
83 Login_Manager.Startup(); // login server
84 }
85 timer1.Enabled = true;
78 timer1.Interval = 200; 86 timer1.Interval = 200;
79 timer1.Elapsed +=new ElapsedEventHandler( this.Timer1Tick ); 87 timer1.Elapsed +=new ElapsedEventHandler( this.Timer1Tick );
80 88
81 89
82 } 90 }
83 public void main_callback( Packet pack, User_Agent_info User_info ) { 91 public void MainCallback( Packet pack, User_Agent_info User_info ) {
84 if( ( pack.Type != PacketType.StartPingCheck ) && ( pack.Type != PacketType.AgentUpdate ) ) { 92 //System.Console.WriteLine(pack.Type);
85 System.Console.WriteLine(pack.Type); 93 if( ( pack.Type != PacketType.StartPingCheck ) && ( pack.Type != PacketType.AgentUpdate ) ) {
94 // System.Console.WriteLine(pack.Type);
86 //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; 95 //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type;
87 } 96 }
88 if( pack.Type == PacketType.AgentSetAppearance ) { 97 if( pack.Type == PacketType.AgentSetAppearance ) {
89 System.Console.WriteLine(pack); 98 // System.Console.WriteLine(pack);
90 //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; 99 //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type;
91 100
92 } 101 }
102 if(pack.Type== PacketType.MapBlockRequest)
103 {
104 //int MinX, MinY, MaxX, MaxY;
105 MapBlockRequestPacket MapRequest=(MapBlockRequestPacket)pack;
106 this.Grid_Manager.RequestMapBlock(User_info,MapRequest.PositionData.MinX,MapRequest.PositionData.MinY,MapRequest.PositionData.MaxX,MapRequest.PositionData.MaxY);
107
108 }
109 if(pack.Type== PacketType.CloseCircuit)
110 {
111 this.Agent_Manager.RemoveAgent(User_info);
112 }
113 if(pack.Type== PacketType.MapLayerRequest)
114 {
115 this.Grid_Manager.RequestMapLayer(User_info);
116
117 }
118 if((pack.Type== PacketType.TeleportRequest ) ||(pack.Type== PacketType.TeleportLocationRequest))
119 {
120 TeleportLocationRequestPacket Request=(TeleportLocationRequestPacket)pack;
121
122 this.Grid_Manager.RequestTeleport(User_info,Request);
123
124 }
93 if( pack.Type == PacketType.TransferRequest ) { 125 if( pack.Type == PacketType.TransferRequest ) {
94 TransferRequestPacket tran = (TransferRequestPacket)pack; 126 TransferRequestPacket tran = (TransferRequestPacket)pack;
95 LLUUID id = new LLUUID( tran.TransferInfo.Params, 0 ); 127 LLUUID id = new LLUUID( tran.TransferInfo.Params, 0 );
96 128
97 if( ( id == new LLUUID( "66c41e39-38f9-f75a-024e-585989bfab73" ) ) || ( id == new LLUUID( "e0ee49b5a4184df8d3c9a65361fe7f49" ) ) ) { 129 if( ( id == new LLUUID( "66c41e39-38f9-f75a-024e-585989bfab73" ) ) || ( id == new LLUUID( "e0ee49b5a4184df8d3c9a65361fe7f49" ) ) ) {
98 //System.Console.WriteLine(pack); 130 Asset_Manager.AddRequest( User_info, id, tran );
99 //System.Console.WriteLine(tran.TransferInfo.TransferID);
100 asset_man.add_request( User_info, id, tran );
101 //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type;
102 } 131 }
103 132
104 } 133 }
@@ -111,23 +140,23 @@ namespace Second_server {
111 } 140 }
112 if( pack.Type == PacketType.CompleteAgentMovement ) { 141 if( pack.Type == PacketType.CompleteAgentMovement ) {
113 // new client 142 // new client
114 agent_man.Agent_join( User_info ); 143 Agent_Manager.AgentJoin( User_info );
115 } 144 }
116 if( pack.Type == PacketType.RequestImage ) { 145 if( pack.Type == PacketType.RequestImage ) {
117 RequestImagePacket image_req = (RequestImagePacket)pack; 146 RequestImagePacket image_req = (RequestImagePacket)pack;
118 for( int i = 0; i < image_req.RequestImage.Length; i++ ) { 147 for( int i = 0; i < image_req.RequestImage.Length; i++ ) {
119 this.texture_man.add_request( User_info, image_req.RequestImage[ i ].Image ); 148 this.Texture_Manager.AddRequest( User_info, image_req.RequestImage[ i ].Image );
120 149
121 } 150 }
122 } 151 }
123 if( pack.Type == PacketType.RegionHandshakeReply ) { 152 if( pack.Type == PacketType.RegionHandshakeReply ) {
124 //recieved regionhandshake so can now start sending info 153 //recieved regionhandshake so can now start sending info
125 agent_man.send_intial_data( User_info ); 154 Agent_Manager.SendInitialData( User_info );
126 //this.setuptemplates("objectupate164.dat",User_info,false); 155 //this.setuptemplates("objectupate164.dat",User_info,false);
127 } 156 }
128 if( pack.Type == PacketType.ObjectAdd ) { 157 if( pack.Type == PacketType.ObjectAdd ) {
129 ObjectAddPacket ad = (ObjectAddPacket)pack; 158 ObjectAddPacket ad = (ObjectAddPacket)pack;
130 prim_man.create_prim( User_info, ad.ObjectData.RayEnd, ad ); 159 Prim_Manager.CreatePrim( User_info, ad.ObjectData.RayEnd, ad );
131 //this.send_prim(User_info,ad.ObjectData.RayEnd, ad); 160 //this.send_prim(User_info,ad.ObjectData.RayEnd, ad);
132 } 161 }
133 if( pack.Type == PacketType.ObjectPosition ) { 162 if( pack.Type == PacketType.ObjectPosition ) {
@@ -141,46 +170,55 @@ namespace Second_server {
141 if( mupd.ObjectData[ i ].Type == 9 ) //change position 170 if( mupd.ObjectData[ i ].Type == 9 ) //change position
142 { 171 {
143 libsecondlife.LLVector3 pos = new LLVector3( mupd.ObjectData[ i ].Data, 0 ); 172 libsecondlife.LLVector3 pos = new LLVector3( mupd.ObjectData[ i ].Data, 0 );
144 173 // libsecondlife.LLQuaternion rot=new LLQuaternion(mupd.ObjectData[i].Data,12,true);
145 prim_man.update_prim_position( User_info, pos.X, pos.Y, pos.Z, mupd.ObjectData[ i ].ObjectLocalID ); 174 Prim_Manager.UpdatePrimPosition( User_info, pos, mupd.ObjectData[ i ].ObjectLocalID ,false ,libsecondlife.LLQuaternion.Identity);
146 //should update stored position of the prim 175 //should update stored position of the prim
147 } 176 }
177 else if( mupd.ObjectData[ i ].Type == 10 )
178 {
179 //System.Console.WriteLine(mupd.ObjectData[ i ].Type);
180 //System.Console.WriteLine(mupd);
181 libsecondlife.LLVector3 pos = new LLVector3(100,100,22);
182 libsecondlife.LLQuaternion rot=new LLQuaternion(mupd.ObjectData[i].Data,0,true);
183 Prim_Manager.UpdatePrimPosition( User_info, pos, mupd.ObjectData[ i ].ObjectLocalID ,true ,rot);
184
185 }
148 } 186 }
149 } 187 }
150 if( pack.Type == PacketType.AgentWearablesRequest ) { 188 if( pack.Type == PacketType.AgentWearablesRequest ) {
151 agent_man.send_intial_avatar_apper( User_info ); 189 Agent_Manager.SendIntialAvatarAppearance( User_info );
152 } 190 }
153 191
154 if( pack.Type == PacketType.AgentUpdate ) { 192 if( pack.Type == PacketType.AgentUpdate ) {
155 AgentUpdatePacket ag = (AgentUpdatePacket)pack; 193 AgentUpdatePacket ag = (AgentUpdatePacket)pack;
156 uint mask = ag.AgentData.ControlFlags & ( 1 ); 194 uint mask = ag.AgentData.ControlFlags & ( 1 );
157 Avatar_data m_av = agent_man.Get_Agent( User_info.AgentID ); 195 AvatarData m_av = Agent_Manager.GetAgent( User_info.AgentID );
158 if( m_av != null ) { 196 if( m_av != null ) {
159 if( m_av.started ) { 197 if( m_av.Started ) {
160 if( mask == ( 1 ) ) { 198 if( mask == ( 1 ) ) {
161 if( !m_av.walk ) { 199 if( !m_av.Walk ) {
162 //start walking 200 //start walking
163 agent_man.send_move_command( User_info, false, m_av.pos.X, m_av.pos.Y, m_av.pos.Z, 0, ag.AgentData.BodyRotation ); 201 Agent_Manager.SendMoveCommand( User_info, false, m_av.Position.X, m_av.Position.Y, m_av.Position.Z, 0, ag.AgentData.BodyRotation );
164 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3( 1, 0, 0 ); 202 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3( 1, 0, 0 );
165 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion( ag.AgentData.BodyRotation.W, ag.AgentData.BodyRotation.X, ag.AgentData.BodyRotation.Y, ag.AgentData.BodyRotation.Z ); 203 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion( ag.AgentData.BodyRotation.W, ag.AgentData.BodyRotation.X, ag.AgentData.BodyRotation.Y, ag.AgentData.BodyRotation.Z );
166 Axiom.MathLib.Vector3 direc = q * v3; 204 Axiom.MathLib.Vector3 direc = q * v3;
167 direc.Normalize(); 205 direc.Normalize();
168 direc = direc * ( ( 0.03f ) * 128f ); 206 direc = direc * ( ( 0.03f ) * 128f );
169 207
170 m_av.vel.X = direc.x; 208 m_av.Velocity.X = direc.x;
171 m_av.vel.Y = direc.y; 209 m_av.Velocity.Y = direc.y;
172 m_av.vel.Z = direc.z; 210 m_av.Velocity.Z = direc.z;
173 m_av.walk = true; 211 m_av.Walk = true;
174 } 212 }
175 } 213 }
176 else { 214 else {
177 if( m_av.walk ) { 215 if( m_av.Walk ) {
178 //walking but key not pressed so need to stop 216 //walking but key not pressed so need to stop
179 agent_man.send_move_command( User_info, true, m_av.pos.X, m_av.pos.Y, m_av.pos.Z, 0, ag.AgentData.BodyRotation ); 217 Agent_Manager.SendMoveCommand( User_info, true, m_av.Position.X, m_av.Position.Y, m_av.Position.Z, 0, ag.AgentData.BodyRotation );
180 m_av.walk = false; 218 m_av.Walk = false;
181 m_av.vel.X = 0; 219 m_av.Velocity.X = 0;
182 m_av.vel.Y = 0; 220 m_av.Velocity.Y = 0;
183 m_av.vel.Z = 0; 221 m_av.Velocity.Z = 0;
184 } 222 }
185 } 223 }
186 } 224 }
@@ -205,25 +243,52 @@ namespace Second_server {
205 else if( comp[ 0 ] == "veloc" ) { 243 else if( comp[ 0 ] == "veloc" ) {
206 } 244 }
207 else { 245 else {
208 agent_man.send_chat_message( User_info, line ); 246 Agent_Manager.SendChatMessage( User_info, line );
209 247
210 } 248 }
211 } 249 }
212 } 250 }
213 } 251 }
214 public void new_user( User_Agent_info User_info ) { 252 public void NewUserCallback( User_Agent_info UserInfo ) {
215 Console.WriteLine( "new user - {0} - has joined [session {1}]", User_info.AgentID.ToString(), User_info.SessionID.ToString() ); 253 Console.WriteLine( "new user - {0} - has joined [session {1}]", UserInfo.AgentID.ToString(), UserInfo.SessionID.ToString() +"curcuit used"+UserInfo.circuitCode);
216 agent_man.New_Agent( User_info ); 254 string first,last;
255 lock(_login)
256 {
257 first=_login.first;
258 last=_login.last;
259
260 //should get agentid and sessionid so they can be checked.
261 }
262 Agent_Manager.NewAgent( UserInfo ,first,last);
263 //now because of the lack of Global account management (User server etc)
264 //we need to reset the names back to default incase a teleport happens
265 //which will not have a Login name set, so they will use default names
266 lock(_login)
267 {
268 _login.first="Test";
269 _login.last="User";
270 }
217 } 271 }
218 272
219 public void error( string text ) { 273 public void ErrorCallback( string text ) {
220 Console.WriteLine( "error report: {0}", text ); 274 Console.WriteLine( "error report: {0}", text );
221 } 275 }
222 276
223 void Timer1Tick( object sender, System.EventArgs e ) { 277 void Timer1Tick( object sender, System.EventArgs e ) {
224 this.time++; 278 this.time++;
225 agent_man.tick(); 279 Agent_Manager.UpdatePositions();
226 texture_man.Do_work( time ); 280 Texture_Manager.DoWork( time );
227 } 281 }
228 } 282 }
229} \ No newline at end of file 283 public class Logon
284 {
285 public string first="Test";
286 public string last="User";
287 public LLUUID Agent;
288 public LLUUID Session;
289 public Logon()
290 {
291
292 }
293 }
294}