RebuildModPaths?
by Daniel Eden · in Torque Game Engine · 05/10/2003 (7:02 am) · 1 replies
I've recently been adding a screenshot management system for the project I'm working on (so that screenshots taken in-game can be viewed in-game and/ or used for loading screens) and hit a bit of a snag.
I was using some code ported in from a script I'd previously written for Tribes 2 that added a number to the screenshot and incremented it each time a new screenshot was taken -- checking automatically to see if a screenshot would be overwritten and skipping that as necessary.
Unfortunately, it made use of RebuildModPaths (a function in Tribes 2 that, from what I can gather, refreshed the resource list for the game) to make sure isFile and similar functions knew that the screenshots existed. As far as I can see there is no equivalent function in Torque at the moment.
I guess what I'm asking is a few things: Was RebuildModPaths deliberately removed from the source (or did it never make it in)? Is there any reason why the function is bad and/ or shouldn't be re-added? Or does anyone have any idea where to start on re-adding it?
It's not a big problem. I can work around it if necessary but it'd be nice to either have or know of a similar call that allows you to perform basically the same function.
I was using some code ported in from a script I'd previously written for Tribes 2 that added a number to the screenshot and incremented it each time a new screenshot was taken -- checking automatically to see if a screenshot would be overwritten and skipping that as necessary.
Unfortunately, it made use of RebuildModPaths (a function in Tribes 2 that, from what I can gather, refreshed the resource list for the game) to make sure isFile and similar functions knew that the screenshots existed. As far as I can see there is no equivalent function in Torque at the moment.
I guess what I'm asking is a few things: Was RebuildModPaths deliberately removed from the source (or did it never make it in)? Is there any reason why the function is bad and/ or shouldn't be re-added? Or does anyone have any idea where to start on re-adding it?
It's not a big problem. I can work around it if necessary but it'd be nice to either have or know of a similar call that allows you to perform basically the same function.
About the author
Torque Owner Harold "LabRat" Brown
To add the function back in open up engine/game/main.cc and locate:
static void cSetModPaths(SimObject*, S32, const char** argv) { char buf[512]; dStrncpy(buf,argv[1], sizeof(buf) - 1); buf[511] = '[[6280fd5125e6e]]'; Vector<char*> paths; char* temp = dStrtok( buf, ";" ); while ( temp ) { if ( temp[0] ) paths.push_back( temp ); temp = dStrtok( NULL, ";" ); } ResourceManager->setModPaths(paths.size(), (const char**) paths.address() ); }Before that add:
[code] const char *defaultPaths[] = { // searched left to right "common" ); static void cRebuildModPaths(SimObject *, S32, const char **) { ResourceManager->setModPaths(sizeof(defaultPaths)/sizeof(char*),defaultPaths); }Next find:
Con::addCommand("setModPaths",cSetModPaths. "setModPaths( paths )", 2, 2 );Before that add:
Con::addCommand("rebuildModPaths",cRebuildModPaths. "rebuildModPaths();", 1, 1 );If you read the code you'll notice that the rebuildModPaths command will set the path list to be only "common" whereas the setModPaths in combination with the getModPaths would allow you to recreate the exact path used on the command line.
Now if you wanted to you could hardcode all of the paths in the defaultPaths array.