1.8 rescource system and error reporting (and more on strings)
by Kirk Longendyke · in Torque Game Engine Advanced · 11/22/2008 (5:10 am) · 1 replies
Another one for the artist friendly crowd:
If any of the 43 possible ::create() functions fail to load for whatever reason during the
void ResourceBase::assign(const ResourceBase &inResource)
function, you're greeted with nothing more than:
Con::errorf("Failed to create resource: [%s]", path.getFullPath().c_str() );
all fine and good if youre one guy tossing in one asset at a time, but for collaboration/upgrade work ect, you'll need a bit more fine-grained feedback on just why. example in this case, would be:
had several dts files failing to load up, with no data other than 'hey i can't make that'. no reason given, so (being the ocd type guy I am when things go pear shaped) tacked in:
This both gave additional feedback, and resolved the underlying issue in this case, wich was: quite a few exporters will export the file with an uppercase extention, wich will not properly resolve to "dts", but "DTS" in the above scenario.
If any of the 43 possible ::create() functions fail to load for whatever reason during the
void ResourceBase::assign(const ResourceBase &inResource)
function, you're greeted with nothing more than:
Con::errorf("Failed to create resource: [%s]", path.getFullPath().c_str() );
all fine and good if youre one guy tossing in one asset at a time, but for collaboration/upgrade work ect, you'll need a bit more fine-grained feedback on just why. example in this case, would be:
had several dts files failing to load up, with no data other than 'hey i can't make that'. no reason given, so (being the ocd type guy I am when things go pear shaped) tacked in:
template<> void *Resource<TSShape>::create(const Torque::Path &path)
{
FileStream stream;
stream.open( path.getFullPath(), Torque::FS::File::Read );
if ( stream.getStatus() != Stream::Ok )
{
Con::errorf("Failed to create TSShape resource: [%s]. Bad Stream Status!", path.getFullPath().c_str() );
return NULL;
}
TSShape * ret = new TSShape;
const String extension = path.getExtension();
bool readSuccess = false;
bool correctformat = false;
if ( extension.ToLower(extension).equal( "dts" ) )
{
correctformat = true;
readSuccess = ret->read(&stream);
}
else if ( extension.ToLower(extension).equal( "md2" ) )
{
correctformat = true;
readSuccess = ret->readMD2(&stream);
}
if (!correctformat) Con::errorf("Failed to create TSShape resource: [%s]. Bad Extention!", path.getFullPath().c_str() );
if( !readSuccess )
{
delete ret;
ret = NULL;
Con::errorf("Failed to create TSShape resource: [%s]. Unable to Read Stream!", path.getFullPath().c_str() );
}
return ret;
}This both gave additional feedback, and resolved the underlying issue in this case, wich was: quite a few exporters will export the file with an uppercase extention, wich will not properly resolve to "dts", but "DTS" in the above scenario.
Associate Rene Damm