summaryrefslogtreecommitdiff
path: root/indra/llprimitive
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2008-06-26 00:39:00 +0000
committerSteven Bennetts <steve@lindenlab.com>2008-06-26 00:39:00 +0000
commit25c10ed028da5c547b11f1f461916897272b0e6d (patch)
tree350a5858f8970b6e28b2dc395625d74d8bd597b2 /indra/llprimitive
parent6dd125d375b38455997a0c4b8747659f4c2351aa (diff)
QAR-628 merge string-cleanup-5 -r 90476:90508 -> release
dataserver-is-deprecated
Diffstat (limited to 'indra/llprimitive')
-rw-r--r--indra/llprimitive/llmaterialtable.cpp29
-rw-r--r--indra/llprimitive/llmaterialtable.h20
-rw-r--r--indra/llprimitive/llprimitive.cpp65
-rw-r--r--indra/llprimitive/llprimitive.h4
4 files changed, 53 insertions, 65 deletions
diff --git a/indra/llprimitive/llmaterialtable.cpp b/indra/llprimitive/llmaterialtable.cpp
index 61c9849144..b3addc720f 100644
--- a/indra/llprimitive/llmaterialtable.cpp
+++ b/indra/llprimitive/llmaterialtable.cpp
@@ -125,14 +125,15 @@ LLMaterialTable::~LLMaterialTable()
void LLMaterialTable::initBasicTable()
{
- add(LL_MCODE_STONE,"Stone", LL_DEFAULT_STONE_UUID);
- add(LL_MCODE_METAL,"Metal", LL_DEFAULT_METAL_UUID);
- add(LL_MCODE_GLASS,"Glass", LL_DEFAULT_GLASS_UUID);
- add(LL_MCODE_WOOD,"Wood", LL_DEFAULT_WOOD_UUID);
- add(LL_MCODE_FLESH,"Flesh", LL_DEFAULT_FLESH_UUID);
- add(LL_MCODE_PLASTIC,"Plastic", LL_DEFAULT_PLASTIC_UUID);
- add(LL_MCODE_RUBBER,"Rubber", LL_DEFAULT_RUBBER_UUID);
- add(LL_MCODE_LIGHT,"Light", LL_DEFAULT_LIGHT_UUID);
+ // *TODO: Translate
+ add(LL_MCODE_STONE,std::string("Stone"), LL_DEFAULT_STONE_UUID);
+ add(LL_MCODE_METAL,std::string("Metal"), LL_DEFAULT_METAL_UUID);
+ add(LL_MCODE_GLASS,std::string("Glass"), LL_DEFAULT_GLASS_UUID);
+ add(LL_MCODE_WOOD,std::string("Wood"), LL_DEFAULT_WOOD_UUID);
+ add(LL_MCODE_FLESH,std::string("Flesh"), LL_DEFAULT_FLESH_UUID);
+ add(LL_MCODE_PLASTIC,std::string("Plastic"), LL_DEFAULT_PLASTIC_UUID);
+ add(LL_MCODE_RUBBER,std::string("Rubber"), LL_DEFAULT_RUBBER_UUID);
+ add(LL_MCODE_LIGHT,std::string("Light"), LL_DEFAULT_LIGHT_UUID);
// specify densities for these materials. . .
// these were taken from http://www.mcelwee.net/html/densities_of_various_materials.html
@@ -331,7 +332,7 @@ void LLMaterialTable::initBasicTable()
}
}
-BOOL LLMaterialTable::add(U8 mcode, const char* name, const LLUUID &uuid)
+BOOL LLMaterialTable::add(U8 mcode, const std::string& name, const LLUUID &uuid)
{
LLMaterialInfo *infop;
@@ -466,13 +467,13 @@ BOOL LLMaterialTable::addDamageAndEnergy(U8 mcode, const F32 &hp_mod, const F32
return FALSE;
}
-LLUUID LLMaterialTable::getDefaultTextureID(char* name)
+LLUUID LLMaterialTable::getDefaultTextureID(const std::string& name)
{
for (info_list_t::iterator iter = mMaterialInfoList.begin();
iter != mMaterialInfoList.end(); ++iter)
{
LLMaterialInfo *infop = *iter;
- if (!strcmp(name, infop->mName))
+ if (name == infop->mName)
{
return infop->mDefaultTextureID;
}
@@ -499,13 +500,13 @@ LLUUID LLMaterialTable::getDefaultTextureID(U8 mcode)
}
-U8 LLMaterialTable::getMCode(const char* name)
+U8 LLMaterialTable::getMCode(const std::string& name)
{
for (info_list_t::iterator iter = mMaterialInfoList.begin();
iter != mMaterialInfoList.end(); ++iter)
{
LLMaterialInfo *infop = *iter;
- if (!strcmp(name, infop->mName))
+ if (name == infop->mName)
{
return infop->mMCode;
}
@@ -515,7 +516,7 @@ U8 LLMaterialTable::getMCode(const char* name)
}
-char* LLMaterialTable::getName(U8 mcode)
+std::string LLMaterialTable::getName(U8 mcode)
{
mcode &= LL_MCODE_MASK;
for (info_list_t::iterator iter = mMaterialInfoList.begin();
diff --git a/indra/llprimitive/llmaterialtable.h b/indra/llprimitive/llmaterialtable.h
index 7dbe7de917..225d1976c0 100644
--- a/indra/llprimitive/llmaterialtable.h
+++ b/indra/llprimitive/llmaterialtable.h
@@ -67,7 +67,7 @@ class LLMaterialInfo
{
public:
U8 mMCode;
- char mName[LLMATERIAL_INFO_NAME_LENGTH]; /* Flawfinder: ignore */
+ std::string mName;
LLUUID mDefaultTextureID;
LLUUID mShatterSoundID;
F32 mDensity; // kg/m^3
@@ -79,24 +79,20 @@ public:
F32 mDamageModifier; // modifier on KE based damage
F32 mEPModifier; // modifier on mass based EP total
- LLMaterialInfo(U8 mcode, const char* name, const LLUUID &uuid)
+ LLMaterialInfo(U8 mcode, const std::string& name, const LLUUID &uuid)
{
init(mcode,name,uuid);
};
- void init(U8 mcode, const char* name, const LLUUID &uuid)
+ void init(U8 mcode, const std::string& name, const LLUUID &uuid)
{
- mName[0] = 0;
mDensity = 1000.f; // default to 1000.0 (water)
mHPModifier = 1.f;
mDamageModifier = 1.f;
mEPModifier = 1.f;
mMCode = mcode;
- if (name)
- {
- LLString::copy(mName,name,LLMATERIAL_INFO_NAME_LENGTH);
- }
+ mName = name;
mDefaultTextureID = uuid;
};
@@ -150,7 +146,7 @@ public:
void initBasicTable();
- BOOL add(U8 mcode, const char* name, const LLUUID &uuid);
+ BOOL add(U8 mcode, const std::string& name, const LLUUID &uuid);
BOOL addCollisionSound(U8 mcode, U8 mcode2, const LLUUID &uuid);
BOOL addSlidingSound(U8 mcode, U8 mcode2, const LLUUID &uuid);
BOOL addRollingSound(U8 mcode, U8 mcode2, const LLUUID &uuid);
@@ -160,10 +156,10 @@ public:
BOOL addRestitution(U8 mcode, const F32 &restitution);
BOOL addDamageAndEnergy(U8 mcode, const F32 &hp_mod, const F32 &damage_mod, const F32 &ep_mod);
- LLUUID getDefaultTextureID(char* name); // LLUUID::null if not found
+ LLUUID getDefaultTextureID(const std::string& name); // LLUUID::null if not found
LLUUID getDefaultTextureID(U8 mcode); // LLUUID::null if not found
- U8 getMCode(const char* name); // 0 if not found
- char* getName(U8 mcode);
+ U8 getMCode(const std::string& name); // 0 if not found
+ std::string getName(U8 mcode);
F32 getDensity(U8 mcode); // kg/m^3, 0 if not found
F32 getFriction(U8 mcode); // physics values
diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp
index ff69cacf0f..90292d8f78 100644
--- a/indra/llprimitive/llprimitive.cpp
+++ b/indra/llprimitive/llprimitive.cpp
@@ -760,15 +760,14 @@ U8 LLPrimitive::pCodeToLegacy(const LLPCode pcode)
// static
// Don't crash or llerrs here! This function is used for debug strings.
-const char * LLPrimitive::pCodeToString(const LLPCode pcode)
+std::string LLPrimitive::pCodeToString(const LLPCode pcode)
{
- static char pcode_string[255]; /* Flawfinder: ignore */
+ std::string pcode_string;
U8 base_code = pcode & LL_PCODE_BASE_MASK;
- pcode_string[0] = 0;
if (!pcode)
{
- snprintf(pcode_string, sizeof(pcode_string), "null"); /* Flawfinder: ignore */
+ pcode_string = "null";
}
else if ((base_code) == LL_PCODE_LEGACY)
{
@@ -776,66 +775,66 @@ const char * LLPrimitive::pCodeToString(const LLPCode pcode)
switch (pcode)
{
case LL_PCODE_LEGACY_GRASS:
- snprintf(pcode_string, sizeof(pcode_string), "grass"); /* Flawfinder: ignore */
+ pcode_string = "grass";
break;
case LL_PCODE_LEGACY_PART_SYS:
- snprintf(pcode_string, sizeof(pcode_string), "particle system"); /* Flawfinder: ignore */
+ pcode_string = "particle system";
break;
case LL_PCODE_LEGACY_AVATAR:
- snprintf(pcode_string, sizeof(pcode_string), "avatar"); /* Flawfinder: ignore */
+ pcode_string = "avatar";
break;
case LL_PCODE_LEGACY_TEXT_BUBBLE:
- snprintf(pcode_string, sizeof(pcode_string), "text bubble"); /* Flawfinder: ignore */
+ pcode_string = "text bubble";
break;
case LL_PCODE_LEGACY_TREE:
- snprintf(pcode_string, sizeof(pcode_string), "tree"); /* Flawfinder: ignore */
+ pcode_string = "tree";
break;
case LL_PCODE_TREE_NEW:
- snprintf(pcode_string, sizeof(pcode_string), "tree_new"); /* Flawfinder: ignore */
+ pcode_string = "tree_new";
break;
default:
- snprintf(pcode_string, sizeof(pcode_string), "unknown legacy pcode %i",(U32)pcode); /* Flawfinder: ignore */
+ pcode_string = llformat( "unknown legacy pcode %i",(U32)pcode);
}
}
else
{
- char shape[32]; /* Flawfinder: ignore */
- char mask[32]; /* Flawfinder: ignore */
+ std::string shape;
+ std::string mask;
if (base_code == LL_PCODE_CUBE)
{
- snprintf(shape, sizeof(shape), "cube"); /* Flawfinder: ignore */
+ shape = "cube";
}
else if (base_code == LL_PCODE_CYLINDER)
{
- snprintf(shape, sizeof(shape), "cylinder"); /* Flawfinder: ignore */
+ shape = "cylinder";
}
else if (base_code == LL_PCODE_CONE)
{
- snprintf(shape, sizeof(shape), "cone"); /* Flawfinder: ignore */
+ shape = "cone";
}
else if (base_code == LL_PCODE_PRISM)
{
- snprintf(shape, sizeof(shape), "prism"); /* Flawfinder: ignore */
+ shape = "prism";
}
else if (base_code == LL_PCODE_PYRAMID)
{
- snprintf(shape, sizeof(shape), "pyramid"); /* Flawfinder: ignore */
+ shape = "pyramid";
}
else if (base_code == LL_PCODE_SPHERE)
{
- snprintf(shape, sizeof(shape), "sphere"); /* Flawfinder: ignore */
+ shape = "sphere";
}
else if (base_code == LL_PCODE_TETRAHEDRON)
{
- snprintf(shape, sizeof(shape), "tetrahedron"); /* Flawfinder: ignore */
+ shape = "tetrahedron";
}
else if (base_code == LL_PCODE_VOLUME)
{
- snprintf(shape, sizeof(shape), "volume"); /* Flawfinder: ignore */
+ shape = "volume";
}
else if (base_code == LL_PCODE_APP)
{
- snprintf(shape, sizeof(shape), "app"); /* Flawfinder: ignore */
+ shape = "app";
}
else
{
@@ -845,35 +844,27 @@ const char * LLPrimitive::pCodeToString(const LLPCode pcode)
U8 mask_code = pcode & (~LL_PCODE_BASE_MASK);
if (base_code == LL_PCODE_APP)
{
- snprintf(mask, sizeof(mask), "%x", mask_code); /* Flawfinder: ignore */
+ mask = llformat( "%x", mask_code);
}
else if (mask_code & LL_PCODE_HEMI_MASK)
{
- snprintf(mask, sizeof(mask), "hemi"); /* Flawfinder: ignore */
+ mask = "hemi";
}
else
{
- snprintf(mask, sizeof(mask), "%x", mask_code); /* Flawfinder: ignore */
+ mask = llformat( "%x", mask_code);
}
- // extra sanity against snprintf() being naturally crap
- mask[sizeof(mask)-1] = '\0';
- shape[sizeof(shape)-1] = '\0';
-
if (mask[0])
{
- snprintf(pcode_string, sizeof(pcode_string), "%s-%s", shape, mask); /* Flawfinder: ignore */
+ pcode_string = llformat( "%s-%s", shape.c_str(), mask.c_str());
}
else
{
- snprintf(pcode_string, sizeof(pcode_string), "%s", shape); /* Flawfinder: ignore */
+ pcode_string = llformat( "%s", shape.c_str());
}
}
- // Be really sure that pcode_string is nul-terminated after we've
- // been using crappy snprintf() to build it.
- pcode_string[sizeof(pcode_string)-1] = '\0';
-
return pcode_string;
}
@@ -993,7 +984,7 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai
S32 i;
/*
- LLString old_mask_string;
+ std::string old_mask_string;
for (i = 0; i < 9; i++)
{
if (old_face_mask & (1 << i))
@@ -1005,7 +996,7 @@ BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detai
old_mask_string.append("0");
}
}
- LLString new_mask_string;
+ std::string new_mask_string;
for (i = 0; i < 9; i++)
{
if (new_face_mask & (1 << i))
diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h
index 2b738f8d29..e243ea623f 100644
--- a/indra/llprimitive/llprimitive.h
+++ b/indra/llprimitive/llprimitive.h
@@ -378,7 +378,7 @@ public:
#endif
LLPCode getPCode() const { return mPrimitiveCode; }
- const char * getPCodeString() const { return pCodeToString(mPrimitiveCode); }
+ std::string getPCodeString() const { return pCodeToString(mPrimitiveCode); }
const LLVector3& getAngularVelocity() const { return mAngularVelocity; }
const LLVector3& getVelocity() const { return mVelocity; }
const LLVector3& getAcceleration() const { return mAcceleration; }
@@ -400,7 +400,7 @@ public:
void removeFlags(U32 flags) { mMiscFlags &= ~flags; }
U32 getFlags() const { return mMiscFlags; }
- static const char *pCodeToString(const LLPCode pcode);
+ static std::string pCodeToString(const LLPCode pcode);
static LLPCode legacyToPCode(const U8 legacy);
static U8 pCodeToLegacy(const LLPCode pcode);
static bool getTESTAxes(const U8 face, U32* s_axis, U32* t_axis);