aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llprimitive/llprimitive.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llprimitive/llprimitive.cpp100
1 files changed, 64 insertions, 36 deletions
diff --git a/linden/indra/llprimitive/llprimitive.cpp b/linden/indra/llprimitive/llprimitive.cpp
index 5fb95c8..859a34f 100644
--- a/linden/indra/llprimitive/llprimitive.cpp
+++ b/linden/indra/llprimitive/llprimitive.cpp
@@ -707,13 +707,13 @@ U8 LLPrimitive::pCodeToLegacy(const LLPCode pcode)
707// Don't crash or llerrs here! This function is used for debug strings. 707// Don't crash or llerrs here! This function is used for debug strings.
708const char * LLPrimitive::pCodeToString(const LLPCode pcode) 708const char * LLPrimitive::pCodeToString(const LLPCode pcode)
709{ 709{
710 static char pcode_string[255]; 710 static char pcode_string[255]; /* Flawfinder: ignore */
711 711
712 U8 base_code = pcode & LL_PCODE_BASE_MASK; 712 U8 base_code = pcode & LL_PCODE_BASE_MASK;
713 pcode_string[0] = 0; 713 pcode_string[0] = 0;
714 if (!pcode) 714 if (!pcode)
715 { 715 {
716 sprintf(pcode_string, "null"); 716 snprintf(pcode_string, sizeof(pcode_string), "null"); /* Flawfinder: ignore */
717 } 717 }
718 else if ((base_code) == LL_PCODE_LEGACY) 718 else if ((base_code) == LL_PCODE_LEGACY)
719 { 719 {
@@ -721,66 +721,66 @@ const char * LLPrimitive::pCodeToString(const LLPCode pcode)
721 switch (pcode) 721 switch (pcode)
722 { 722 {
723 case LL_PCODE_LEGACY_GRASS: 723 case LL_PCODE_LEGACY_GRASS:
724 sprintf(pcode_string, "grass"); 724 snprintf(pcode_string, sizeof(pcode_string), "grass"); /* Flawfinder: ignore */
725 break; 725 break;
726 case LL_PCODE_LEGACY_PART_SYS: 726 case LL_PCODE_LEGACY_PART_SYS:
727 sprintf(pcode_string, "particle system"); 727 snprintf(pcode_string, sizeof(pcode_string), "particle system"); /* Flawfinder: ignore */
728 break; 728 break;
729 case LL_PCODE_LEGACY_AVATAR: 729 case LL_PCODE_LEGACY_AVATAR:
730 sprintf(pcode_string, "avatar"); 730 snprintf(pcode_string, sizeof(pcode_string), "avatar"); /* Flawfinder: ignore */
731 break; 731 break;
732 case LL_PCODE_LEGACY_TEXT_BUBBLE: 732 case LL_PCODE_LEGACY_TEXT_BUBBLE:
733 sprintf(pcode_string, "text bubble"); 733 snprintf(pcode_string, sizeof(pcode_string), "text bubble"); /* Flawfinder: ignore */
734 break; 734 break;
735 case LL_PCODE_LEGACY_TREE: 735 case LL_PCODE_LEGACY_TREE:
736 sprintf(pcode_string, "tree"); 736 snprintf(pcode_string, sizeof(pcode_string), "tree"); /* Flawfinder: ignore */
737 break; 737 break;
738 case LL_PCODE_TREE_NEW: 738 case LL_PCODE_TREE_NEW:
739 sprintf(pcode_string, "tree_new"); 739 snprintf(pcode_string, sizeof(pcode_string), "tree_new"); /* Flawfinder: ignore */
740 break; 740 break;
741 default: 741 default:
742 sprintf(pcode_string, "unknown legacy pcode %i",(U32)pcode); 742 snprintf(pcode_string, sizeof(pcode_string), "unknown legacy pcode %i",(U32)pcode); /* Flawfinder: ignore */
743 } 743 }
744 } 744 }
745 else 745 else
746 { 746 {
747 char shape[32]; 747 char shape[32]; /* Flawfinder: ignore */
748 char mask[32]; 748 char mask[32]; /* Flawfinder: ignore */
749 if (base_code == LL_PCODE_CUBE) 749 if (base_code == LL_PCODE_CUBE)
750 { 750 {
751 sprintf(shape, "cube"); 751 snprintf(shape, sizeof(shape), "cube"); /* Flawfinder: ignore */
752 } 752 }
753 else if (base_code == LL_PCODE_CYLINDER) 753 else if (base_code == LL_PCODE_CYLINDER)
754 { 754 {
755 sprintf(shape, "cylinder"); 755 snprintf(shape, sizeof(shape), "cylinder"); /* Flawfinder: ignore */
756 } 756 }
757 else if (base_code == LL_PCODE_CONE) 757 else if (base_code == LL_PCODE_CONE)
758 { 758 {
759 sprintf(shape, "cone"); 759 snprintf(shape, sizeof(shape), "cone"); /* Flawfinder: ignore */
760 } 760 }
761 else if (base_code == LL_PCODE_PRISM) 761 else if (base_code == LL_PCODE_PRISM)
762 { 762 {
763 sprintf(shape, "prism"); 763 snprintf(shape, sizeof(shape), "prism"); /* Flawfinder: ignore */
764 } 764 }
765 else if (base_code == LL_PCODE_PYRAMID) 765 else if (base_code == LL_PCODE_PYRAMID)
766 { 766 {
767 sprintf(shape, "pyramid"); 767 snprintf(shape, sizeof(shape), "pyramid"); /* Flawfinder: ignore */
768 } 768 }
769 else if (base_code == LL_PCODE_SPHERE) 769 else if (base_code == LL_PCODE_SPHERE)
770 { 770 {
771 sprintf(shape, "sphere"); 771 snprintf(shape, sizeof(shape), "sphere"); /* Flawfinder: ignore */
772 } 772 }
773 else if (base_code == LL_PCODE_TETRAHEDRON) 773 else if (base_code == LL_PCODE_TETRAHEDRON)
774 { 774 {
775 sprintf(shape, "tetrahedron"); 775 snprintf(shape, sizeof(shape), "tetrahedron"); /* Flawfinder: ignore */
776 } 776 }
777 else if (base_code == LL_PCODE_VOLUME) 777 else if (base_code == LL_PCODE_VOLUME)
778 { 778 {
779 sprintf(shape, "volume"); 779 snprintf(shape, sizeof(shape), "volume"); /* Flawfinder: ignore */
780 } 780 }
781 else if (base_code == LL_PCODE_APP) 781 else if (base_code == LL_PCODE_APP)
782 { 782 {
783 sprintf(shape, "app"); 783 snprintf(shape, sizeof(shape), "app"); /* Flawfinder: ignore */
784 } 784 }
785 else 785 else
786 { 786 {
@@ -790,15 +790,15 @@ const char * LLPrimitive::pCodeToString(const LLPCode pcode)
790 U8 mask_code = pcode & (~LL_PCODE_BASE_MASK); 790 U8 mask_code = pcode & (~LL_PCODE_BASE_MASK);
791 if (base_code == LL_PCODE_APP) 791 if (base_code == LL_PCODE_APP)
792 { 792 {
793 sprintf(mask, "%x", mask_code); 793 snprintf(mask, sizeof(mask), "%x", mask_code); /* Flawfinder: ignore */
794 } 794 }
795 else if (mask_code & LL_PCODE_HEMI_MASK) 795 else if (mask_code & LL_PCODE_HEMI_MASK)
796 { 796 {
797 sprintf(mask, "hemi"); 797 snprintf(mask, sizeof(mask), "hemi"); /* Flawfinder: ignore */
798 } 798 }
799 else if (mask != 0) 799 else if (mask != 0)
800 { 800 {
801 sprintf(mask, "%x", mask_code); 801 snprintf(mask, sizeof(mask), "%x", mask_code); /* Flawfinder: ignore */
802 } 802 }
803 else 803 else
804 { 804 {
@@ -807,11 +807,11 @@ const char * LLPrimitive::pCodeToString(const LLPCode pcode)
807 807
808 if (mask[0]) 808 if (mask[0])
809 { 809 {
810 sprintf(pcode_string, "%s-%s", shape, mask); 810 snprintf(pcode_string, sizeof(pcode_string), "%s-%s", shape, mask); /* Flawfinder: ignore */
811 } 811 }
812 else 812 else
813 { 813 {
814 sprintf(pcode_string, "%s", shape); 814 snprintf(pcode_string, sizeof(pcode_string), "%s", shape); /* Flawfinder: ignore */
815 } 815 }
816 } 816 }
817 return pcode_string; 817 return pcode_string;
@@ -1197,7 +1197,7 @@ S32 LLPrimitive::packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_fa
1197 { 1197 {
1198 if (!memcmp(data_ptr+(data_size *face_index), data_ptr+(data_size *i), data_size)) 1198 if (!memcmp(data_ptr+(data_size *face_index), data_ptr+(data_size *i), data_size))
1199 { 1199 {
1200 exception_faces |= (1 << i); 1200 exception_faces |= ((U64)1 << i);
1201 } 1201 }
1202 } 1202 }
1203 1203
@@ -1238,7 +1238,7 @@ S32 LLPrimitive::unpackTEField(U8 *cur_ptr, U8 *buffer_end, U8 *data_ptr, U8 dat
1238 for (i = 1; i < face_count; i++) 1238 for (i = 1; i < face_count; i++)
1239 { 1239 {
1240 // Already unswizzled, don't need to unswizzle it again! 1240 // Already unswizzled, don't need to unswizzle it again!
1241 memcpy(data_ptr+(i*data_size),data_ptr,data_size); 1241 memcpy(data_ptr+(i*data_size),data_ptr,data_size); /* Flawfinder: ignore */
1242 } 1242 }
1243 1243
1244 while ((cur_ptr < buffer_end) && (*cur_ptr != 0)) 1244 while ((cur_ptr < buffer_end) && (*cur_ptr != 0))
@@ -1301,7 +1301,7 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const
1301 for (face_index = 0; face_index <= last_face_index; face_index++) 1301 for (face_index = 0; face_index <= last_face_index; face_index++)
1302 { 1302 {
1303 // Directly sending image_ids is not safe! 1303 // Directly sending image_ids is not safe!
1304 memcpy(&image_ids[face_index*16],getTE(face_index)->getID().mData,16); 1304 memcpy(&image_ids[face_index*16],getTE(face_index)->getID().mData,16); /* Flawfinder: ignore */
1305 1305
1306 // Cast LLColor4 to LLColor4U 1306 // Cast LLColor4 to LLColor4U
1307 coloru.setVec( getTE(face_index)->getColor() ); 1307 coloru.setVec( getTE(face_index)->getColor() );
@@ -1377,7 +1377,7 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const
1377 for (face_index = 0; face_index <= last_face_index; face_index++) 1377 for (face_index = 0; face_index <= last_face_index; face_index++)
1378 { 1378 {
1379 // Directly sending image_ids is not safe! 1379 // Directly sending image_ids is not safe!
1380 memcpy(&image_ids[face_index*16],getTE(face_index)->getID().mData,16); 1380 memcpy(&image_ids[face_index*16],getTE(face_index)->getID().mData,16); /* Flawfinder: ignore */
1381 1381
1382 // Cast LLColor4 to LLColor4U 1382 // Cast LLColor4 to LLColor4U
1383 coloru.setVec( getTE(face_index)->getColor() ); 1383 coloru.setVec( getTE(face_index)->getColor() );
@@ -1588,7 +1588,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp)
1588 for (i = 0; i < face_count; i++) 1588 for (i = 0; i < face_count; i++)
1589 { 1589 {
1590// llinfos << "BUMP unpack (Datapacker) [" << i << "]=" << S32(bump[i]) <<llendl; 1590// llinfos << "BUMP unpack (Datapacker) [" << i << "]=" << S32(bump[i]) <<llendl;
1591 memcpy(image_ids[i].mData,&image_data[i*16],16); 1591 memcpy(image_ids[i].mData,&image_data[i*16],16); /* Flawfinder: ignore */
1592 } 1592 }
1593 1593
1594 LLColor4 color; 1594 LLColor4 color;
@@ -1628,6 +1628,24 @@ void LLPrimitive::setTextureList(LLTextureEntry *listp)
1628 1628
1629//============================================================================ 1629//============================================================================
1630 1630
1631//static
1632BOOL LLNetworkData::isValid(U16 param_type, U32 size)
1633{
1634 // ew - better mechanism needed
1635
1636 switch(param_type)
1637 {
1638 case PARAMS_FLEXIBLE:
1639 return (size == 16);
1640 case PARAMS_LIGHT:
1641 return (size == 16);
1642 }
1643
1644 return FALSE;
1645}
1646
1647//============================================================================
1648
1631LLLightParams::LLLightParams() 1649LLLightParams::LLLightParams()
1632{ 1650{
1633 mColor.setToWhite(); 1651 mColor.setToWhite();
@@ -1650,12 +1668,22 @@ BOOL LLLightParams::pack(LLDataPacker &dp) const
1650 1668
1651BOOL LLLightParams::unpack(LLDataPacker &dp) 1669BOOL LLLightParams::unpack(LLDataPacker &dp)
1652{ 1670{
1653 LLColor4U color4u; 1671 LLColor4U color;
1654 dp.unpackColor4U(color4u, "color"); 1672 dp.unpackColor4U(color, "color");
1655 mColor = LLColor4(color4u); 1673 setColor(LLColor4(color));
1656 dp.unpackF32(mRadius, "radius"); 1674
1657 dp.unpackF32(mCutoff, "cutoff"); 1675 F32 radius;
1658 dp.unpackF32(mFalloff, "falloff"); 1676 dp.unpackF32(radius, "radius");
1677 setRadius(radius);
1678
1679 F32 cutoff;
1680 dp.unpackF32(cutoff, "cutoff");
1681 setCutoff(cutoff);
1682
1683 F32 falloff;
1684 dp.unpackF32(falloff, "falloff");
1685 setFalloff(falloff);
1686
1659 return TRUE; 1687 return TRUE;
1660} 1688}
1661 1689