diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-09-24 20:53:55 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-09-24 20:53:55 +0000 |
commit | b50a2fe4fc4789277f4d78fbb95b227039f50fc4 (patch) | |
tree | ec85542a063430a7a0ff1b3500ecabf13dafb5a7 /crawl-ref/source/newgame.cc | |
parent | 8ff8b514bd6f983e092b1ddddda6f29b5dd5197b (diff) | |
download | crawl-ref-b50a2fe4fc4789277f4d78fbb95b227039f50fc4.tar.gz crawl-ref-b50a2fe4fc4789277f4d78fbb95b227039f50fc4.zip |
More cleanups of file handling.
Removed the useless "anticheat check."
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup@108 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/newgame.cc')
-rw-r--r-- | crawl-ref/source/newgame.cc | 61 |
1 files changed, 10 insertions, 51 deletions
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index c68c9893e3..dce5049a28 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -284,76 +284,35 @@ static void pick_random_species_and_class( void ) static bool check_saved_game(void) { FILE *handle; - char char_fil[kFileNameSize]; -#ifdef LOAD_UNPACKAGE_CMD - // Create the file name base - char name_buff[kFileNameLen]; - - snprintf( name_buff, sizeof(name_buff), -#ifdef SAVE_DIR_PATH - SAVE_DIR_PATH -#endif -#ifdef MULTIUSER - "%s%d", -#else - "%s", -#endif - you.your_name -#ifdef MULTIUSER - , (int) getuid() -#endif - ); - - char zip_buff[kFileNameLen]; - - strcpy(zip_buff, name_buff); - strcat(zip_buff, PACKAGE_SUFFIX); - - // Create save dir name - strcpy(char_fil, name_buff); - strcat(char_fil, ".sav"); + std::string basename = get_savedir_filename( you.your_name, "", ""); + std::string savename = basename + ".sav"; - handle = fopen(zip_buff, "rb+"); +#ifdef LOAD_UNPACKAGE_CMD + std::string zipname = basename + PACKAGE_SUFFIX; + handle = fopen(zipname.c_str(), "rb+"); if (handle != NULL) { + fclose(handle); cprintf(EOL "Loading game..." EOL); // Create command char cmd_buff[1024]; - snprintf( cmd_buff, sizeof(cmd_buff), LOAD_UNPACKAGE_CMD, name_buff ); + snprintf( cmd_buff, sizeof(cmd_buff), LOAD_UNPACKAGE_CMD, + basename.c_str() ); if (system( cmd_buff ) != 0) { cprintf( EOL "Warning: Zip command (LOAD_UNPACKAGE_CMD) returned non-zero value!" EOL ); } - fclose(handle); - // Remove save game package - unlink(zip_buff); + unlink(zipname.c_str()); } - else - { -#ifdef DO_ANTICHEAT_CHECKS - // Simple security patch -- must have zip file otherwise invalidate - // the character. Right now this just renames the .sav file to - // .bak, allowing anyone with the appropriate permissions to - // fix a character in the case of a bug. This could be changed - // to unlinking the file(s) which would remove the character. - strcat(name_buff, ".bak"); - rename(char_fil, name_buff); -#endif - } - -#else - strcpy(char_fil, ""); - strncat(char_fil, you.your_name, kFileNameLen); - strcat(char_fil, ".sav"); #endif - handle = fopen(char_fil, "rb+"); + handle = fopen(savename.c_str(), "rb+"); if (handle != NULL) { |