Replaced unsafe c string usage with std::string
This commit is contained in:
@@ -50,12 +50,12 @@ bool trpgHeader::isValid() const
|
||||
else {
|
||||
if (numLods <= 0)
|
||||
{
|
||||
strcpy(errMess, "Number of LOD <= 0");
|
||||
errMess.assign("Number of LOD <= 0");
|
||||
return false;
|
||||
}
|
||||
if (sw.x == ne.x && sw.y == ne.y)
|
||||
{
|
||||
strcpy(errMess, "Mbr is invalid");
|
||||
errMess.assign("Mbr is invalid");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -618,11 +618,11 @@ public:
|
||||
*/
|
||||
virtual bool Print(trpgPrintBuffer &) const { return true; }
|
||||
|
||||
const char *getErrMess() const {if(errMess[0] == '\0') return 0;else return &errMess[0];}
|
||||
const char *getErrMess() const { return errMess.empty() ? 0 : errMess.c_str();}
|
||||
|
||||
protected:
|
||||
|
||||
mutable char errMess[512];
|
||||
mutable std::string errMess;
|
||||
};
|
||||
|
||||
/* Pointer into a trpgwAppFile. The full name of the file
|
||||
|
||||
@@ -949,7 +949,7 @@ bool trpgLightTable::isValid() const
|
||||
if (!itr->second.isValid())
|
||||
{
|
||||
if(itr->second.getErrMess())
|
||||
strcpy(errMess, itr->second.getErrMess());
|
||||
errMess.assign(itr->second.getErrMess());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1629,14 +1629,14 @@ bool trpgTexTable::isValid() const
|
||||
{
|
||||
if (!textureMap.size())
|
||||
{
|
||||
strcpy(errMess, "Texture table list is empty");
|
||||
errMess.assign("Texture table list is empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
TextureMapType::const_iterator itr = textureMap.begin();
|
||||
for ( ; itr != textureMap.end( ); itr++) {
|
||||
if(!itr->second.isValid()) {
|
||||
strcpy(errMess, "A texture in the texture table is invalid");
|
||||
errMess.assign("A texture in the texture table is invalid");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ bool trpgModel::isValid() const
|
||||
{
|
||||
if (type == External && !name)
|
||||
{
|
||||
strcpy(errMess, "Model is external with no name");
|
||||
errMess.assign("Model is external with no name");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ bool trpgModelTable::isValid() const
|
||||
for ( ; itr != modelsMap.end( ); itr++) {
|
||||
if(!itr->second.isValid()) {
|
||||
if(itr->second.getErrMess())
|
||||
strcpy(errMess, itr->second.getErrMess());
|
||||
errMess.assign(itr->second.getErrMess());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user