Replaced unsafe c string usage with std::string

This commit is contained in:
Robert Osfield
2016-06-28 16:03:01 +01:00
parent 7f1ba5f7df
commit b5f880ba1d
5 changed files with 9 additions and 9 deletions

View File

@@ -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;
}

View File

@@ -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

View 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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}