- attmpt to auto-create the screens folder at startup to avoid crashes when folder is missing and users try to take a screenshot.

This commit is contained in:
Mark Vejvoda 2010-08-02 03:15:11 +00:00
parent c9393024ce
commit 4e8fdc105c
4 changed files with 22 additions and 10 deletions

View File

@ -937,16 +937,19 @@ void Game::keyDown(char key){
showFullConsole= true;
}
else if(key == configKeys.getCharKey("Screenshot")) {
for(int i=0; i<100; ++i){
string path= "screens/screen" + intToStr(i) + ".tga";
FILE *f= fopen(path.c_str(), "rb");
if(f==NULL){
Renderer::getInstance().saveScreen(path);
break;
}
else{
fclose(f);
string path = GameConstants::folder_path_screenshots;
if(isdir(path.c_str()) == true) {
for(int i=0; i<100; ++i){
path = GameConstants::folder_path_screenshots;
path += "screen" + intToStr(i) + ".tga";
FILE *f= fopen(path.c_str(), "rb");
if(f==NULL) {
Renderer::getInstance().saveScreen(path);
break;
}
else {
fclose(f);
}
}
}
}

View File

@ -64,6 +64,8 @@ public:
static const char *folder_path_tutorials;
static const char *NETWORK_SLOT_UNCONNECTED_SLOTNAME;
static const char *folder_path_screenshots;
};
enum PathType {

View File

@ -38,6 +38,8 @@ const char *GameConstants::folder_path_tutorials = "tutorials";
const char *GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME = "???";
const char *GameConstants::folder_path_screenshots = "screens/";
// =====================================================
// class Config
// =====================================================

View File

@ -663,6 +663,11 @@ int glestMain(int argc, char** argv){
gameInitialized = true;
string screenShotsPath = GameConstants::folder_path_screenshots;
if(isdir(screenShotsPath.c_str()) == false) {
createDirectoryPaths(screenShotsPath);
}
if(config.getBool("AllowGameDataSynchCheck","false") == true) {
vector<string> techDataPaths = config.getPathListForType(ptTechs);
preCacheThread.reset(new FileCRCPreCacheThread());