diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SOPVehicle.cs | 194 |
1 files changed, 117 insertions, 77 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs index b462867..d3c2d27 100644 --- a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs | |||
@@ -484,45 +484,91 @@ namespace OpenSim.Region.Framework.Scenes | |||
484 | writer = null; | 484 | writer = null; |
485 | } | 485 | } |
486 | 486 | ||
487 | private int XRint(XmlTextReader reader, string name) | 487 | |
488 | |||
489 | XmlTextReader reader; | ||
490 | |||
491 | private int XRint() | ||
488 | { | 492 | { |
489 | return reader.ReadElementContentAsInt(name, String.Empty); | 493 | return reader.ReadElementContentAsInt(); |
490 | } | 494 | } |
491 | 495 | ||
492 | private float XRfloat(XmlTextReader reader, string name) | 496 | private float XRfloat() |
493 | { | 497 | { |
494 | return reader.ReadElementContentAsFloat(name, String.Empty); | 498 | return reader.ReadElementContentAsFloat(); |
495 | } | 499 | } |
496 | 500 | ||
497 | public Vector3 XRvector(XmlTextReader reader, string name) | 501 | public Vector3 XRvector() |
498 | { | 502 | { |
499 | Vector3 vec; | 503 | Vector3 vec; |
500 | reader.ReadStartElement(name); | 504 | reader.ReadStartElement(); |
501 | vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x | 505 | vec.X = reader.ReadElementContentAsFloat(); |
502 | vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or y | 506 | vec.Y = reader.ReadElementContentAsFloat(); |
503 | vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z | 507 | vec.Z = reader.ReadElementContentAsFloat(); |
504 | reader.ReadEndElement(); | 508 | reader.ReadEndElement(); |
505 | return vec; | 509 | return vec; |
506 | } | 510 | } |
507 | 511 | ||
508 | public Quaternion XRquat(XmlTextReader reader, string name) | 512 | public Quaternion XRquat() |
509 | { | 513 | { |
510 | Quaternion q; | 514 | Quaternion q; |
511 | reader.ReadStartElement(name); | 515 | reader.ReadStartElement(); |
512 | q.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | 516 | q.X = reader.ReadElementContentAsFloat(); |
513 | q.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | 517 | q.Y = reader.ReadElementContentAsFloat(); |
514 | q.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | 518 | q.Z = reader.ReadElementContentAsFloat(); |
515 | q.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | 519 | q.W = reader.ReadElementContentAsFloat(); |
516 | reader.ReadEndElement(); | 520 | reader.ReadEndElement(); |
517 | return q; | 521 | return q; |
518 | } | 522 | } |
519 | 523 | ||
520 | public void FromXml2(XmlTextReader reader, out bool errors) | 524 | public static bool EReadProcessors( |
525 | Dictionary<string, Action> processors, | ||
526 | XmlTextReader xtr) | ||
527 | { | ||
528 | bool errors = false; | ||
529 | |||
530 | string nodeName = string.Empty; | ||
531 | while (xtr.NodeType != XmlNodeType.EndElement) | ||
532 | { | ||
533 | nodeName = xtr.Name; | ||
534 | |||
535 | // m_log.DebugFormat("[ExternalRepresentationUtils]: Processing: {0}", nodeName); | ||
536 | |||
537 | Action p = null; | ||
538 | if (processors.TryGetValue(xtr.Name, out p)) | ||
539 | { | ||
540 | // m_log.DebugFormat("[ExternalRepresentationUtils]: Found {0} processor, nodeName); | ||
541 | |||
542 | try | ||
543 | { | ||
544 | p(); | ||
545 | } | ||
546 | catch (Exception e) | ||
547 | { | ||
548 | errors = true; | ||
549 | if (xtr.NodeType == XmlNodeType.EndElement) | ||
550 | xtr.Read(); | ||
551 | } | ||
552 | } | ||
553 | else | ||
554 | { | ||
555 | // m_log.DebugFormat("[LandDataSerializer]: caught unknown element {0}", nodeName); | ||
556 | xtr.ReadOuterXml(); // ignore | ||
557 | } | ||
558 | } | ||
559 | |||
560 | return errors; | ||
561 | } | ||
562 | |||
563 | |||
564 | |||
565 | public void FromXml2(XmlTextReader _reader, out bool errors) | ||
521 | { | 566 | { |
522 | errors = false; | 567 | errors = false; |
568 | reader = _reader; | ||
523 | 569 | ||
524 | Dictionary<string, Action<VehicleData, XmlTextReader>> m_VehicleXmlProcessors | 570 | Dictionary<string, Action> m_VehicleXmlProcessors |
525 | = new Dictionary<string, Action<VehicleData, XmlTextReader>>(); | 571 | = new Dictionary<string, Action>(); |
526 | 572 | ||
527 | m_VehicleXmlProcessors.Add("TYPE", ProcessXR_type); | 573 | m_VehicleXmlProcessors.Add("TYPE", ProcessXR_type); |
528 | m_VehicleXmlProcessors.Add("FLAGS", ProcessXR_flags); | 574 | m_VehicleXmlProcessors.Add("FLAGS", ProcessXR_flags); |
@@ -568,135 +614,129 @@ namespace OpenSim.Region.Framework.Scenes | |||
568 | 614 | ||
569 | reader.ReadStartElement("Vehicle", String.Empty); | 615 | reader.ReadStartElement("Vehicle", String.Empty); |
570 | 616 | ||
571 | errors = ExternalRepresentationUtils.ExecuteReadProcessors( | 617 | errors = EReadProcessors( |
572 | vd, | ||
573 | m_VehicleXmlProcessors, | 618 | m_VehicleXmlProcessors, |
574 | reader, | 619 | reader); |
575 | (o, nodeName, e) | ||
576 | => | ||
577 | { | ||
578 | } | ||
579 | ); | ||
580 | 620 | ||
581 | reader.ReadEndElement(); | 621 | reader.ReadEndElement(); |
622 | reader = null; | ||
582 | } | 623 | } |
583 | 624 | ||
584 | private void ProcessXR_type(VehicleData obj, XmlTextReader reader) | 625 | private void ProcessXR_type() |
585 | { | 626 | { |
586 | vd.m_type = (Vehicle)XRint(reader, "TYPE"); | 627 | vd.m_type = (Vehicle)XRint(); |
587 | } | 628 | } |
588 | private void ProcessXR_flags(VehicleData obj, XmlTextReader reader) | 629 | private void ProcessXR_flags() |
589 | { | 630 | { |
590 | vd.m_flags = (VehicleFlag)XRint(reader, "FLAGS"); | 631 | vd.m_flags = (VehicleFlag)XRint(); |
591 | } | 632 | } |
592 | // Linear properties | 633 | // Linear properties |
593 | private void ProcessXR_linearMotorDirection(VehicleData obj, XmlTextReader reader) | 634 | private void ProcessXR_linearMotorDirection() |
594 | { | 635 | { |
595 | vd.m_linearMotorDirection = XRvector(reader, "LMDIR"); | 636 | vd.m_linearMotorDirection = XRvector(); |
596 | } | 637 | } |
597 | 638 | ||
598 | private void ProcessXR_linearFrictionTimescale(VehicleData obj, XmlTextReader reader) | 639 | private void ProcessXR_linearFrictionTimescale() |
599 | { | 640 | { |
600 | vd.m_linearFrictionTimescale = XRvector(reader, "LMFTIME"); | 641 | vd.m_linearFrictionTimescale = XRvector(); |
601 | } | 642 | } |
602 | 643 | ||
603 | private void ProcessXR_linearMotorDecayTimescale(VehicleData obj, XmlTextReader reader) | 644 | private void ProcessXR_linearMotorDecayTimescale() |
604 | { | 645 | { |
605 | vd.m_linearMotorDecayTimescale = XRfloat(reader, "LMDTIME"); | 646 | vd.m_linearMotorDecayTimescale = XRfloat(); |
606 | } | 647 | } |
607 | private void ProcessXR_linearMotorTimescale(VehicleData obj, XmlTextReader reader) | 648 | private void ProcessXR_linearMotorTimescale() |
608 | { | 649 | { |
609 | vd.m_linearMotorTimescale = XRfloat(reader, "LMTIME"); | 650 | vd.m_linearMotorTimescale = XRfloat(); |
610 | } | 651 | } |
611 | private void ProcessXR_linearMotorOffset(VehicleData obj, XmlTextReader reader) | 652 | private void ProcessXR_linearMotorOffset() |
612 | { | 653 | { |
613 | vd.m_linearMotorOffset = XRvector(reader, "LMOFF"); | 654 | vd.m_linearMotorOffset = XRvector(); |
614 | } | 655 | } |
615 | 656 | ||
616 | 657 | ||
617 | //Angular properties | 658 | //Angular properties |
618 | private void ProcessXR_angularMotorDirection(VehicleData obj, XmlTextReader reader) | 659 | private void ProcessXR_angularMotorDirection() |
619 | { | 660 | { |
620 | vd.m_angularMotorDirection = XRvector(reader, "AMDIR"); | 661 | vd.m_angularMotorDirection = XRvector(); |
621 | } | 662 | } |
622 | private void ProcessXR_angularMotorTimescale(VehicleData obj, XmlTextReader reader) | 663 | private void ProcessXR_angularMotorTimescale() |
623 | { | 664 | { |
624 | vd.m_angularMotorTimescale = XRfloat(reader, "AMTIME"); | 665 | vd.m_angularMotorTimescale = XRfloat(); |
625 | } | 666 | } |
626 | private void ProcessXR_angularMotorDecayTimescale(VehicleData obj, XmlTextReader reader) | 667 | private void ProcessXR_angularMotorDecayTimescale() |
627 | { | 668 | { |
628 | vd.m_angularMotorDecayTimescale = XRfloat(reader, "AMDTIME"); | 669 | vd.m_angularMotorDecayTimescale = XRfloat(); |
629 | } | 670 | } |
630 | private void ProcessXR_angularFrictionTimescale(VehicleData obj, XmlTextReader reader) | 671 | private void ProcessXR_angularFrictionTimescale() |
631 | { | 672 | { |
632 | vd.m_angularFrictionTimescale = XRvector(reader, "AMFTIME"); | 673 | vd.m_angularFrictionTimescale = XRvector(); |
633 | } | 674 | } |
634 | 675 | ||
635 | //Deflection properties | 676 | //Deflection properties |
636 | private void ProcessXR_angularDeflectionEfficiency(VehicleData obj, XmlTextReader reader) | 677 | private void ProcessXR_angularDeflectionEfficiency() |
637 | { | 678 | { |
638 | vd.m_angularDeflectionEfficiency = XRfloat(reader, "ADEFF"); | 679 | vd.m_angularDeflectionEfficiency = XRfloat(); |
639 | } | 680 | } |
640 | private void ProcessXR_angularDeflectionTimescale(VehicleData obj, XmlTextReader reader) | 681 | private void ProcessXR_angularDeflectionTimescale() |
641 | { | 682 | { |
642 | vd.m_angularDeflectionTimescale = XRfloat(reader, "ADTIME"); | 683 | vd.m_angularDeflectionTimescale = XRfloat(); |
643 | } | 684 | } |
644 | private void ProcessXR_linearDeflectionEfficiency(VehicleData obj, XmlTextReader reader) | 685 | private void ProcessXR_linearDeflectionEfficiency() |
645 | { | 686 | { |
646 | vd.m_linearDeflectionEfficiency = XRfloat(reader, "LDEFF"); | 687 | vd.m_linearDeflectionEfficiency = XRfloat(); |
647 | } | 688 | } |
648 | private void ProcessXR_linearDeflectionTimescale(VehicleData obj, XmlTextReader reader) | 689 | private void ProcessXR_linearDeflectionTimescale() |
649 | { | 690 | { |
650 | vd.m_linearDeflectionTimescale = XRfloat(reader, "LDTIME"); | 691 | vd.m_linearDeflectionTimescale = XRfloat(); |
651 | } | 692 | } |
652 | 693 | ||
653 | //Banking properties | 694 | //Banking properties |
654 | private void ProcessXR_bankingEfficiency(VehicleData obj, XmlTextReader reader) | 695 | private void ProcessXR_bankingEfficiency() |
655 | { | 696 | { |
656 | vd.m_bankingEfficiency = XRfloat(reader, "BEFF"); | 697 | vd.m_bankingEfficiency = XRfloat(); |
657 | } | 698 | } |
658 | private void ProcessXR_bankingMix(VehicleData obj, XmlTextReader reader) | 699 | private void ProcessXR_bankingMix() |
659 | { | 700 | { |
660 | vd.m_bankingMix = XRfloat(reader, "BMIX"); | 701 | vd.m_bankingMix = XRfloat(); |
661 | } | 702 | } |
662 | private void ProcessXR_bankingTimescale(VehicleData obj, XmlTextReader reader) | 703 | private void ProcessXR_bankingTimescale() |
663 | { | 704 | { |
664 | vd.m_bankingTimescale = XRfloat(reader, "BTIME"); | 705 | vd.m_bankingTimescale = XRfloat(); |
665 | } | 706 | } |
666 | 707 | ||
667 | //Hover and Buoyancy properties | 708 | //Hover and Buoyancy properties |
668 | private void ProcessXR_VhoverHeight(VehicleData obj, XmlTextReader reader) | 709 | private void ProcessXR_VhoverHeight() |
669 | { | 710 | { |
670 | vd.m_VhoverHeight = XRfloat(reader, "HHEI"); | 711 | vd.m_VhoverHeight = XRfloat(); |
671 | } | 712 | } |
672 | private void ProcessXR_VhoverEfficiency(VehicleData obj, XmlTextReader reader) | 713 | private void ProcessXR_VhoverEfficiency() |
673 | { | 714 | { |
674 | vd.m_VhoverEfficiency = XRfloat(reader, "HEFF"); | 715 | vd.m_VhoverEfficiency = XRfloat(); |
675 | } | 716 | } |
676 | private void ProcessXR_VhoverTimescale(VehicleData obj, XmlTextReader reader) | 717 | private void ProcessXR_VhoverTimescale() |
677 | { | 718 | { |
678 | vd.m_VhoverTimescale = XRfloat(reader, "HTIME"); | 719 | vd.m_VhoverTimescale = XRfloat(); |
679 | } | 720 | } |
680 | 721 | ||
681 | private void ProcessXR_VehicleBuoyancy(VehicleData obj, XmlTextReader reader) | 722 | private void ProcessXR_VehicleBuoyancy() |
682 | { | 723 | { |
683 | vd.m_VehicleBuoyancy = XRfloat(reader, "VBUO"); | 724 | vd.m_VehicleBuoyancy = XRfloat(); |
684 | } | 725 | } |
685 | 726 | ||
686 | //Attractor properties | 727 | //Attractor properties |
687 | private void ProcessXR_verticalAttractionEfficiency(VehicleData obj, XmlTextReader reader) | 728 | private void ProcessXR_verticalAttractionEfficiency() |
688 | { | 729 | { |
689 | vd.m_verticalAttractionEfficiency = XRfloat(reader, "VAEFF"); | 730 | vd.m_verticalAttractionEfficiency = XRfloat(); |
690 | } | 731 | } |
691 | private void ProcessXR_verticalAttractionTimescale(VehicleData obj, XmlTextReader reader) | 732 | private void ProcessXR_verticalAttractionTimescale() |
692 | { | 733 | { |
693 | vd.m_verticalAttractionTimescale = XRfloat(reader, "VATIME"); | 734 | vd.m_verticalAttractionTimescale = XRfloat(); |
694 | } | 735 | } |
695 | 736 | ||
696 | private void ProcessXR_referenceFrame(VehicleData obj, XmlTextReader reader) | 737 | private void ProcessXR_referenceFrame() |
697 | { | 738 | { |
698 | vd.m_referenceFrame = XRquat(reader, "REF_FRAME"); | 739 | vd.m_referenceFrame = XRquat(); |
699 | |||
700 | } | 740 | } |
701 | } | 741 | } |
702 | } \ No newline at end of file | 742 | } \ No newline at end of file |