aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Agent_Manager.cs
diff options
context:
space:
mode:
authorMW2007-02-03 21:09:54 +0000
committerMW2007-02-03 21:09:54 +0000
commitdc2316de9c7a7168263e7a367b4c69189f9bc232 (patch)
tree57b639a77d585f5ded98f283d24a02617faf5b1a /Agent_Manager.cs
parent(no commit message) (diff)
downloadopensim-SC_OLD-dc2316de9c7a7168263e7a367b4c69189f9bc232.zip
opensim-SC_OLD-dc2316de9c7a7168263e7a367b4c69189f9bc232.tar.gz
opensim-SC_OLD-dc2316de9c7a7168263e7a367b4c69189f9bc232.tar.bz2
opensim-SC_OLD-dc2316de9c7a7168263e7a367b4c69189f9bc232.tar.xz
Basic Inventory support and clean up
Diffstat (limited to 'Agent_Manager.cs')
-rw-r--r--Agent_Manager.cs367
1 files changed, 177 insertions, 190 deletions
diff --git a/Agent_Manager.cs b/Agent_Manager.cs
index 2f5ceba..769ee2a 100644
--- a/Agent_Manager.cs
+++ b/Agent_Manager.cs
@@ -207,30 +207,18 @@ namespace OpenSim
207 /// <param name="name"></param> 207 /// <param name="name"></param>
208 private void SetupTemplate(string name) 208 private void SetupTemplate(string name)
209 { 209 {
210 /*ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); 210
211 objupdate.RegionData.RegionHandle=1096213093147648;
212 objupdate.RegionData.TimeDilation=64096;
213 objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
214 */
215 int i=0; 211 int i=0;
216 FileInfo fInfo = new FileInfo(name); 212 FileInfo fInfo = new FileInfo(name);
217
218 long numBytes = fInfo.Length; 213 long numBytes = fInfo.Length;
219
220 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); 214 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
221
222 BinaryReader br = new BinaryReader(fStream); 215 BinaryReader br = new BinaryReader(fStream);
223
224 byte [] data1 = br.ReadBytes((int)numBytes); 216 byte [] data1 = br.ReadBytes((int)numBytes);
225
226 br.Close(); 217 br.Close();
227
228 fStream.Close(); 218 fStream.Close();
229 219
230 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i); 220 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i);
231 221
232 //objupdate.ObjectData[0]=objdata;
233
234 System.Text.Encoding enc = System.Text.Encoding.ASCII; 222 System.Text.Encoding enc = System.Text.Encoding.ASCII;
235 libsecondlife.LLVector3 pos=new LLVector3(objdata.ObjectData, 16); 223 libsecondlife.LLVector3 pos=new LLVector3(objdata.ObjectData, 16);
236 pos.X=100f; 224 pos.X=100f;
@@ -238,8 +226,7 @@ namespace OpenSim
238 objdata.NameValue=enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); 226 objdata.NameValue=enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
239 libsecondlife.LLVector3 pos2=new LLVector3(13.981f,100.0f,20.0f); 227 libsecondlife.LLVector3 pos2=new LLVector3(13.981f,100.0f,20.0f);
240 //objdata.FullID=user.AgentID; 228 //objdata.FullID=user.AgentID;
241 byte[] pb=pos.GetBytes(); 229 byte[] pb=pos.GetBytes();
242
243 Array.Copy(pb,0,objdata.ObjectData,16,pb.Length); 230 Array.Copy(pb,0,objdata.ObjectData,16,pb.Length);
244 231
245 AvatarTemplate=objdata; 232 AvatarTemplate=objdata;
@@ -254,50 +241,50 @@ namespace OpenSim
254 { 241 {
255 242
256 //shouldn't have to read all this in from disk for every new client 243 //shouldn't have to read all this in from disk for every new client
257 string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\layer_data\"; 244 string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\layer_data\";
258 245
259 //send layerdata 246 //send layerdata
260 LayerDataPacket layerpack=new LayerDataPacket(); 247 LayerDataPacket layerpack=new LayerDataPacket();
261 layerpack.LayerID.Type=76; 248 layerpack.LayerID.Type=76;
262 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata0.dat"); 249 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata0.dat");
263 250
264 LayerDataPacket layerpack1=new LayerDataPacket(); 251 LayerDataPacket layerpack1=new LayerDataPacket();
265 layerpack1.LayerID.Type=76; 252 layerpack1.LayerID.Type=76;
266 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata1.dat"); 253 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata1.dat");
267 254
268 LayerDataPacket layerpack2=new LayerDataPacket(); 255 LayerDataPacket layerpack2=new LayerDataPacket();
269 layerpack2.LayerID.Type=56; 256 layerpack2.LayerID.Type=56;
270 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata2.dat"); 257 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata2.dat");
271 258
272 LayerDataPacket layerpack3=new LayerDataPacket(); 259 LayerDataPacket layerpack3=new LayerDataPacket();
273 layerpack3.LayerID.Type=55; 260 layerpack3.LayerID.Type=55;
274 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata3.dat"); 261 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata3.dat");
275 262
276 LayerDataPacket layerpack4=new LayerDataPacket(); 263 LayerDataPacket layerpack4=new LayerDataPacket();
277 layerpack4.LayerID.Type=56; 264 layerpack4.LayerID.Type=56;
278 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata4.dat"); 265 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata4.dat");
279 266
280 LayerDataPacket layerpack5=new LayerDataPacket(); 267 LayerDataPacket layerpack5=new LayerDataPacket();
281 layerpack5.LayerID.Type=55; 268 layerpack5.LayerID.Type=55;
282 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata5.dat"); 269 this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata5.dat");
283 270
284 //send intial set of captured prims data? 271 //send intial set of captured prims data?
285 this.Prim_Manager.ReadPrimDatabase( "objectdatabase.ini",User_info); 272 this.Prim_Manager.ReadPrimDatabase( "objectdatabase.ini",User_info);
286 273
287 //send prims that have been created by users 274 //send prims that have been created by users
288 //prim_man.send_existing_prims(User_info); 275 //prim_man.send_existing_prims(User_info);
289 276
290 //send update about clients avatar 277 //send update about clients avatar
291 this.SendInitialAvatarPosition(User_info); 278 this.SendInitialAvatarPosition(User_info);
292 279
293 //send updates about all other users 280 //send updates about all other users
294 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) 281 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList)
282 {
283 if(kp.Value.NetInfo.AgentID!=User_info.AgentID)
295 { 284 {
296 if(kp.Value.NetInfo.AgentID!=User_info.AgentID) 285 this.SendOtherAvatarPosition(User_info,kp.Value);
297 { 286 }
298 this.SendOtherAvatarPosition(User_info,kp.Value); 287 }
299 }
300 }
301 } 288 }
302 289
303 /// <summary> 290 /// <summary>
@@ -456,26 +443,26 @@ namespace OpenSim
456 /// <param name="line"></param> 443 /// <param name="line"></param>
457 public void SendChatMessage(User_Agent_info User_info, string line) 444 public void SendChatMessage(User_Agent_info User_info, string line)
458 { 445 {
459 libsecondlife.Packets.ChatFromSimulatorPacket reply=new ChatFromSimulatorPacket(); 446 libsecondlife.Packets.ChatFromSimulatorPacket reply=new ChatFromSimulatorPacket();
460 reply.ChatData.Audible=1; 447 reply.ChatData.Audible=1;
461 reply.ChatData.Message=enc.GetBytes(line); 448 reply.ChatData.Message=enc.GetBytes(line);
462 reply.ChatData.ChatType=1; 449 reply.ChatData.ChatType=1;
463 reply.ChatData.SourceType=1; 450 reply.ChatData.SourceType=1;
464 reply.ChatData.Position=new LLVector3(120,100,21); //should set to actual position 451 reply.ChatData.Position=new LLVector3(120,100,21); //should set to actual position
465 reply.ChatData.FromName=enc.GetBytes(User_info.first_name +" "+User_info.last_name +"\0"); //enc.GetBytes("Echo: \0"); //and actual name 452 reply.ChatData.FromName=enc.GetBytes(User_info.first_name +" "+User_info.last_name +"\0"); //enc.GetBytes("Echo: \0"); //and actual name
466 reply.ChatData.OwnerID=User_info.AgentID; 453 reply.ChatData.OwnerID=User_info.AgentID;
467 reply.ChatData.SourceID=User_info.AgentID; 454 reply.ChatData.SourceID=User_info.AgentID;
468 //echo to sender 455 //echo to sender
469 server.SendPacket(reply,true,User_info); 456 server.SendPacket(reply,true,User_info);
470 457
471 //send to all users 458 //send to all users
472 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) 459 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList)
473 { 460 {
474 if(kp.Value.NetInfo.AgentID!=User_info.AgentID) 461 if(kp.Value.NetInfo.AgentID!=User_info.AgentID)
475 { 462 {
476 server.SendPacket(reply,true,kp.Value.NetInfo); 463 server.SendPacket(reply,true,kp.Value.NetInfo);
477 } 464 }
478 } 465 }
479 } 466 }
480 467
481 /// <summary> 468 /// <summary>
@@ -490,121 +477,121 @@ namespace OpenSim
490 /// <param name="body"></param> 477 /// <param name="body"></param>
491 public void SendMoveCommand(User_Agent_info user, bool stop,float x, float y, float z, uint av_id, libsecondlife.LLQuaternion body) 478 public void SendMoveCommand(User_Agent_info user, bool stop,float x, float y, float z, uint av_id, libsecondlife.LLQuaternion body)
492 { 479 {
493 uint ID=user.localID; 480 uint ID=user.localID;
494 //ID=av_id; 481 //ID=av_id;
495 byte[] bytes=new byte[60]; 482 byte[] bytes=new byte[60];
496 483
497 ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); 484 ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket();
498 im.RegionData.RegionHandle=Globals.Instance.RegionHandle;; 485 im.RegionData.RegionHandle=Globals.Instance.RegionHandle;;
499 im.RegionData.TimeDilation=64096; 486 im.RegionData.TimeDilation=64096;
500 487
501 im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 488 im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
502 int i=0; 489 int i=0;
503 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); 490 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
504 491
505 im.ObjectData[0]=dat; 492 im.ObjectData[0]=dat;
506 493
507 dat.TextureEntry=AvatarTemplate.TextureEntry; 494 dat.TextureEntry=AvatarTemplate.TextureEntry;
508 libsecondlife.LLVector3 pos2=new LLVector3(x,y,z); 495 libsecondlife.LLVector3 pos2=new LLVector3(x,y,z);
509 496
510 bytes[i++] = (byte)(ID % 256); 497 bytes[i++] = (byte)(ID % 256);
511 bytes[i++] = (byte)((ID >> 8) % 256); 498 bytes[i++] = (byte)((ID >> 8) % 256);
512 bytes[i++] = (byte)((ID >> 16) % 256); 499 bytes[i++] = (byte)((ID >> 16) % 256);
513 bytes[i++] = (byte)((ID >> 24) % 256); 500 bytes[i++] = (byte)((ID >> 24) % 256);
514 501
515 bytes[i++]=0; 502 bytes[i++]=0;
516 bytes[i++]=1; 503 bytes[i++]=1;
517 504
518 i+=14; 505 i+=14;
519 bytes[i++]=128; 506 bytes[i++]=128;
520 bytes[i++]=63; 507 bytes[i++]=63;
521 byte[] pb=pos2.GetBytes(); 508 byte[] pb=pos2.GetBytes();
522 509
523 Array.Copy(pb,0,bytes,i,pb.Length); 510 Array.Copy(pb,0,bytes,i,pb.Length);
524 i+=12; 511 i+=12;
525 ushort ac=32767; 512 ushort ac=32767;
526 Axiom.MathLib.Vector3 v3=new Axiom.MathLib.Vector3(1,0,0); 513 Axiom.MathLib.Vector3 v3=new Axiom.MathLib.Vector3(1,0,0);
527 Axiom.MathLib.Quaternion q=new Axiom.MathLib.Quaternion(body.W,body.X,body.Y,body.Z); 514 Axiom.MathLib.Quaternion q=new Axiom.MathLib.Quaternion(body.W,body.X,body.Y,body.Z);
528 Axiom.MathLib.Vector3 direc=q*v3; 515 Axiom.MathLib.Vector3 direc=q*v3;
529 direc.Normalize(); 516 direc.Normalize();
530 517
531 direc=direc*(0.03f); 518 direc=direc*(0.03f);
532 direc.x+=1; 519 direc.x+=1;
533 direc.y+=1; 520 direc.y+=1;
534 direc.z+=1; 521 direc.z+=1;
535 ushort dx,dy,dz; 522 ushort dx,dy,dz;
536 dx=(ushort)(32768*direc.x); 523 dx=(ushort)(32768*direc.x);
537 dy=(ushort)(32768*direc.y); 524 dy=(ushort)(32768*direc.y);
538 dz=(ushort)(32768*direc.z); 525 dz=(ushort)(32768*direc.z);
539 526
540 //vel 527 //vel
541 if(!stop) 528 if(!stop)
542 { 529 {
543 bytes[i++] = (byte)(dx % 256); 530 bytes[i++] = (byte)(dx % 256);
544 bytes[i++] = (byte)((dx >> 8) % 256); 531 bytes[i++] = (byte)((dx >> 8) % 256);
545 532
546 bytes[i++] = (byte)(dy % 256); 533 bytes[i++] = (byte)(dy % 256);
547 bytes[i++] = (byte)((dy >> 8) % 256); 534 bytes[i++] = (byte)((dy >> 8) % 256);
548 535
549 bytes[i++] = (byte)(dz % 256); 536 bytes[i++] = (byte)(dz % 256);
550 bytes[i++] = (byte)((dz >> 8) % 256); 537 bytes[i++] = (byte)((dz >> 8) % 256);
551 } 538 }
552 else 539 else
553 { 540 {
554 bytes[i++] = (byte)(ac % 256); 541 bytes[i++] = (byte)(ac % 256);
555 bytes[i++] = (byte)((ac >> 8) % 256); 542 bytes[i++] = (byte)((ac >> 8) % 256);
556 543
557 bytes[i++] = (byte)(ac % 256); 544 bytes[i++] = (byte)(ac % 256);
558 bytes[i++] = (byte)((ac >> 8) % 256); 545 bytes[i++] = (byte)((ac >> 8) % 256);
559 546
560 bytes[i++] = (byte)(ac % 256); 547 bytes[i++] = (byte)(ac % 256);
561 bytes[i++] = (byte)((ac >> 8) % 256); 548 bytes[i++] = (byte)((ac >> 8) % 256);
562 } 549 }
563 //accel 550 //accel
564 bytes[i++] = (byte)(ac % 256); 551 bytes[i++] = (byte)(ac % 256);
565 bytes[i++] = (byte)((ac >> 8) % 256); 552 bytes[i++] = (byte)((ac >> 8) % 256);
566 553
567 bytes[i++] = (byte)(ac % 256); 554 bytes[i++] = (byte)(ac % 256);
568 bytes[i++] = (byte)((ac >> 8) % 256); 555 bytes[i++] = (byte)((ac >> 8) % 256);
569 556
570 bytes[i++] = (byte)(ac % 256); 557 bytes[i++] = (byte)(ac % 256);
571 bytes[i++] = (byte)((ac >> 8) % 256); 558 bytes[i++] = (byte)((ac >> 8) % 256);
572 559
573 //rot 560 //rot
574 bytes[i++] = (byte)(ac % 256); 561 bytes[i++] = (byte)(ac % 256);
575 bytes[i++] = (byte)((ac >> 8) % 256); 562 bytes[i++] = (byte)((ac >> 8) % 256);
576 563
577 bytes[i++] = (byte)(ac % 256); 564 bytes[i++] = (byte)(ac % 256);
578 bytes[i++] = (byte)((ac >> 8) % 256); 565 bytes[i++] = (byte)((ac >> 8) % 256);
579 566
580 bytes[i++] = (byte)(ac % 256); 567 bytes[i++] = (byte)(ac % 256);
581 bytes[i++] = (byte)((ac >> 8) % 256); 568 bytes[i++] = (byte)((ac >> 8) % 256);
582 569
583 bytes[i++] = (byte)(ac % 256); 570 bytes[i++] = (byte)(ac % 256);
584 bytes[i++] = (byte)((ac >> 8) % 256); 571 bytes[i++] = (byte)((ac >> 8) % 256);
585 572
586 //rotation vel 573 //rotation vel
587 bytes[i++] = (byte)(ac % 256); 574 bytes[i++] = (byte)(ac % 256);
588 bytes[i++] = (byte)((ac >> 8) % 256); 575 bytes[i++] = (byte)((ac >> 8) % 256);
589 576
590 bytes[i++] = (byte)(ac % 256); 577 bytes[i++] = (byte)(ac % 256);
591 bytes[i++] = (byte)((ac >> 8) % 256); 578 bytes[i++] = (byte)((ac >> 8) % 256);
592 579
593 bytes[i++] = (byte)(ac % 256); 580 bytes[i++] = (byte)(ac % 256);
594 bytes[i++] = (byte)((ac >> 8) % 256); 581 bytes[i++] = (byte)((ac >> 8) % 256);
595 582
596 dat.Data=bytes; 583 dat.Data=bytes;
597 584
598 server.SendPacket(im,true,user); 585 server.SendPacket(im,true,user);
599 586
600 //should send to all users. 587 //should send to all users.
601 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) 588 foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList)
602 { 589 {
603 if(kp.Value.NetInfo.AgentID!=user.AgentID) 590 if(kp.Value.NetInfo.AgentID!=user.AgentID)
604 { 591 {
605 server.SendPacket(im,true,kp.Value.NetInfo); 592 server.SendPacket(im,true,kp.Value.NetInfo);
606 } 593 }
607 } 594 }
608 } 595 }
609 596
610 /// <summary> 597 /// <summary>